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?

有帮助吗?

解决方案

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

Try with this.

其他提示

Just solved this one.

What I did was add the following in my Upstart script:

respawn

pre-start script

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

end script

exec /etc/init.d/ntpd start

That works like a charm. I think Upstart does pay much attention to the statements order.

Thanks!!!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top