What is the best way to get Upstart to send me an email notification if the job stops working?

Here is an example of a job that I have running. I would like to receive a notification if it comes out, because it is important that it remains.

(I know php is not the best tool for this, but it's someone else code, so whatever)

/etc/init/watchdog.conf

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
script
    exec $PHP_PATH/php -f $WD_PATH/index.php wd_run
end script
+4
source share
1 answer

You can add a start script message that will send an email if the service is updated -

post-start script
    echo "my-foo service started at `date +"%F %T.%N"`" | mail -s "My-foo Service Started" you@example.com
end script

Similarly, you can use post-stop:

post-stop script
    echo "my-foo service stopped at `date +"%F %T.%N"`" | mail -s "My-foo Service Stopped" you@example.com
end script
+5
source

All Articles