重新生成进程时,Upstart脚本不执行预启动脚本

时间:2014-01-27 15:37:25

标签: bash centos6 upstart

我正试图让Upstart在重新生成进程时向我发送电子邮件。 所以,关注upstart节,这是我的ntpd服务的新手脚本(仅作为示例):

/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

然后,我重新加载进程(initctl reload ntpd)以便让upstart重新加载ntpd.conf的配置。然后kill -9强制重生的过程。 这是/var/log/message.log

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

电子邮件永远不会发送。我尝试过post-start和exec,但它也不起作用。

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

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

试试这个。

答案 1 :(得分:0)

刚刚解决了这个问题。

我所做的是在我的Upstart脚本中添加以下内容:

respawn

pre-start script

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

end script

exec /etc/init.d/ntpd start

这就像一个魅力。 我认为Upstart非常关注语句顺序。

感谢!!!