Score:0

Service to monitor Service not triggering

ng flag

On Ubuntu 18 I have a service :

[Unit]
Description=Gets CSV
OnFailure=pushovercsv.service

[Service]
ExecStart=/usr/bin/vehicles.sh

[Install]
WantedBy=multi-user.target

This works. I am trying unsuccessfully to setup another service which alerts me if the first service is stopped or in failed sate:

pushovercsv.service

[Unit]
Description=PushOver Notifaction for vehicles CSV Service

[Service]
Type=simple
ExecStart=curl -s --form-string "token=<secret>" --form-string "user=<secret>" --form-string "message=CSV service"   https://<pushover api endpoint>

[Install]
WantedBy=multi-user.target

Both services work on there own.

But it doesn't appear as if OnFailure=pushovercsv.service is calling the pushover service. If I stop the first service with systemctl stop service1 I get no alert from pushovercsv.service.

Does pushovercsv.service need to be manually started or is it started when called?

Score:1
um flag

As its name suggests, OnFailure= is only triggered when the unit fails (exits with a non-zero exit code, killed by a signal, or similar). If you want to run a command whenever the service stops, you don't even need a separate service, just ExecStopPost= is enough.

Al Grant avatar
ng flag
So if I include OnFailure and ExecStopPost it will trigger on Failure or Stop?
iBug avatar
um flag
@AlGrant They'll act separately. If the service fails, both `OnFailure` unit and `ExecStopPost` command will be started/executed.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.