Search code examples
bashcentos6upstart

Upstart script not executing pre-start script when the process is respawned


I'm trying to get Upstart sending me e-mails when a process is respawned. So, following upstart stanzas, here's my upstart script for ntpd service (just as an example):

/etc/init/ntpd.conf

### ntpd

script

mail -s "ntpd Service Respawned" my_email@gmail.com
control + D

end script

respawn

exec /etc/init.d/ntpd start

Then, I reload the process (initctl reload ntpd) in order to get upstart to reload ntpd.conf's config. Then kill -9 the process to force its respawn. Here's /var/log/message.log:

init: ntpd main process (12446) killed by KILL signal
init: ntpd main process ended, respawning

And the e-mail is never sent. I've tried with post-start and exec but it doesn't work either.

Any advice?


Solution

  • echo "ntpd Service Respawned" | mail -s "ntpd Service Respawned" my_email@gmail.com
    

    Try with this.