2014-01-27 129 views
1

我试图让Upstart在进程重新生成时向我发送电子邮件。 所以,以下新贵节,这是我的新贵脚本ntpd的服务(就像一个例子):当进程重新生成时,Upstart脚本不执行预启动脚本

/etc/init/ntpd.conf 

### ntpd 

script 

mail -s "ntpd Service Respawned" [email protected] 
control + D 

end script 

respawn 

exec /etc/init.d/ntpd start 

然后,我重装过程(initctl reload ntpd)为了得到新贵重装ntpd.conf的配置。然后kill -9强制其重生的过程。 这里的/var/log/message.log

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

与电子邮件不会发送。我已经尝试过后启动和exec,但它也不起作用。

有什么建议吗?

回答

1
echo "ntpd Service Respawned" | mail -s "ntpd Service Respawned" [email protected] 

试试这个。

0

刚刚解决了这个问题。

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

 
respawn 

pre-start script 

mail -s "ntpd Service Respawned" [email protected] 
control + D 

end script 

exec /etc/init.d/ntpd start 

这就像一个魅力。 我认为Upstart对报表订单非常重视。

谢谢!

+1

对于未来的读者,问题可能在于OP在同一个新贵脚本中同时使用'script'和'exec'。这是不允许的。修复(我相信)是使用'pre-start'而不是'script'。订单在很大程度上并不重要。 –