How to send an email alert when a linux service has stopped?
Solution 1:
You can use the ExecStopPost
setting in your service configuration, as documented in systemd.service to send an email whenever the service stops. If you don't want to receive an email when the service exits cleanly, you can use the SERVICE_RESULT
environment variable (documented in systemd.exec) in the script sending the email.