php – 如果作业停止运行,让Upstart向我发送电子邮件通知的最佳方法是什么?

这是我运行的工作的一个例子.如果它退出,我想收到通知,因为它保持不变是很重要的.

(我知道php不是最好的工具,但它是别人的代码,所以,无论如何)

/etc/init/watchdog.conf

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
script
    exec $PHP_PATH/php -f $WD_PATH/index.php wd_run
end script

解决方法:

您可以添加一个发布后脚本,如果重新生成服务,该脚本将发送电子邮件 –

post-start script
    echo "my-foo service started at `date +"%F %T.%N"`" | mail -s "My-foo Service Started" you@example.com
end script

同样你可以使用post-stop:

post-stop script
    echo "my-foo service stopped at `date +"%F %T.%N"`" | mail -s "My-foo Service Stopped" you@example.com
end script

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...