0

I have a service that I only need systemd to run ExecStart= command at boot, and don't run the ExecStop action at shutdown / reboot.

Is that possible?

I can't just remove the ExecStop line, 'cause sometimes I need to shutdown the service manually. A live example is apparmor service, you need to activate all profiles on start, but no need to disable any of them at system shutdown.

0

You can set ExecStop to a wrapper script which first detects the conditions (like being in the shotdown process) under which you (don't) want the real stop code be executed and then either calls the real ExecStop entry or just aborts.

| improve this answer | |
  • How to detect the shutdown event? – daisy Jul 4 '13 at 12:16
  • @warl0ck E.g. with the output of runlevel. – Hauke Laging Jul 4 '13 at 12:20
  • runlevel works for systemd? Mine returns unknown ... – daisy Jul 4 '13 at 12:21
  • @warl0ck There is a systemd version for runlevel which is installed here and works... Maybe you should make that a separate question. Probably the "runlevel" change is logged somewhere (dmesg?). Maybe this info can be taken from other systemd commands (systemctl list-jobs?). – Hauke Laging Jul 4 '13 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.