4

Here is an example of a job I have running. I'd like to receive a notification if it exits, because it's important that it stays up.

(I know php isn't the best tool for this, but it's someone else's 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
Gabriel Alack
  • 472
  • 2
  • 6
  • 16

1 Answers1

4

You can add a post start script that would send an e-mail if the service is respawned -

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

Likewise you could 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
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119