简体   繁体   中英

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?

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

试试这个。

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!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM