systemd start a service when another is killed/dead

by vyom   Last Updated August 01, 2020 10:00 AM - source

Is there a way to start another service (or run a script) when my service enters inactive (dead) state ?

For e.g., in upstart, I had

 start on stopped <otherjob>

In systemd, I see on OnFailure= - which is for cases when the service fails to start. In my case, the daemon in running, but then gets killed (due to a signal, say), how can I invoke another service (trigger start of another systemd service unit or a script)? .

Note: my service has Restart=no, if I check in a script invoked from ExecStopPost= then I cannot distinguish between SIGTERM sent by user or other process vs SIGTERM sent by systemd. I would rather want systemd to do the script/service invocation when my service dies (goes inactive/dead)



Related Questions




Ubuntu 16.04 Systemd not possible to use systemctl

Updated November 13, 2016 08:00 AM