简体   繁体   English

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

[英]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. 重新启动进程时,我试图让Upstart向我发送电子邮件。 So, following upstart stanzas, here's my upstart script for ntpd service (just as an example): 因此,遵循新贵节,这是我的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

Then, I reload the process ( initctl reload ntpd ) in order to get upstart to reload ntpd.conf's config. 然后,我重新加载进程( initctl reload ntpd ),以便重新启动ntpd.conf的配置。 Then kill -9 the process to force its respawn. 然后kill -9以强制其重生。 Here's /var/log/message.log : 这是/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. 我已经尝试过使用post-start和exec,但是它也不起作用。

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: 我所做的是在Upstart脚本中添加以下内容:

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. 我认为Upstart确实非常注意语句顺序。

Thanks!!! 谢谢!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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