linux shell脚本监控进程崩溃自动重启

来源:互联网 发布:犀牛软件破解教程 编辑:程序博客网 时间:2024/04/29 23:35
  • linux shell脚本监控进程崩溃自动重启,由于目前有Python实现的通讯组件时不时会异常中断,在还没有找到问题的解决办法时先暂时用shell监控并自动重启处理。
# ! /bin/shbasepath=$(cd `dirname $0`; pwd)while truedo    procnum=`ps -ef|grep "服务名称"|grep -v grep|wc -l`    if [ $procnum -eq 0 ]    then        启动命令        echo `date +%Y-%m-%d` `date +%H:%M:%S`  "restart 服务" >>$basepath/shell.log    fi    sleep 1done

后台执行 nohup ./shell.sh &

阅读全文
0 0
原创粉丝点击