Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
@abhinavkorpal
abhinavkorpal / README-oneshot-systemd-service.md
Created March 7, 2018 06:22 — forked from drmalex07/README-oneshot-systemd-service.md
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh: