扫码关注官方订阅号
假设存在一个task.py,由于长时间工作内存溢出的问题,可能终止。如何检测他停止任务,立即重启他?
task.py
import time while(1): print('.') # 模拟异常终止 sleep(2) exit(0)
感谢!!!!!
闭关修行中......
supervisord
也可以利用 systemd:
Restart=always RestartSec=0
supervisor
写一个shell脚本
function check(){ count=`ps -ef |grep $1 |grep -v "grep" |wc -l` #echo $count if [ 0 == $count ];then nohup python $1 & fi }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
supervisord
也可以利用 systemd:
supervisor
写一个shell脚本