2014-01-27 127 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'。訂單在很大程度上並不重要。 –