Bash 重新启动进程时,Upstart脚本不执行预启动脚本
我试图让暴发户在流程重新启动时向我发送电子邮件。 下面是我为ntpd服务编写的upstart脚本(仅作为示例): 然后,我重新加载进程(Bash 重新启动进程时,Upstart脚本不执行预启动脚本,bash,centos6,upstart,Bash,Centos6,Upstart,我试图让暴发户在流程重新启动时向我发送电子邮件。 下面是我为ntpd服务编写的upstart脚本(仅作为示例): 然后,我重新加载进程(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, respaw
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,但都不起作用
有什么建议吗
echo "ntpd Service Respawned" | mail -s "ntpd Service Respawned" my_email@gmail.com
试试这个。刚刚解决了这个问题
我所做的是在我的Upstart脚本中添加以下内容:
respawn
pre-start script
mail -s "ntpd Service Respawned" my_address@gmail.com
control + D
end script
exec /etc/init.d/ntpd start
重生
预启动脚本
邮件-s“ntpd服务重新启用”我的_address@gmail.com
控制+D
结束脚本
exec/etc/init.d/ntpd start
这很有魅力。
我认为“暴发户”确实非常注意语句顺序
谢谢 对于未来的读者来说,问题可能是toop在同一个upstart脚本中同时使用了
script
和exec
。这是不允许的。修复方法(我相信)是使用预启动
而不是脚本
。秩序在很大程度上并不重要。
respawn
pre-start script
mail -s "ntpd Service Respawned" my_address@gmail.com
control + D
end script
exec /etc/init.d/ntpd start