zoukankan      html  css  js  c++  java
  • linux监控脚本状态失败后拉起

    while true   # 无限循环
    flag=`ps -aux |grep "consumer.py" |grep -v "grep" |wc -l`
    do
            if [[ $flag -eq 0 ]]   # 判断进程数如果等于0,则启动脚本
            then
                    `python3 -u consumer.py >> radius.log 2>&1 &`   # 启动脚本
                    echo `date` - "consumer.py restart" >> running.log   # 将重启时间写入自定义的日志文件
            else
                    echo "consumer.py is running..." >> /dev/null
            fi
            sleep 3s  # 延迟3秒后进入下次循环
    done
  • 相关阅读:
    作业三3
    作业三2(改过)
    第一章
    实验2
    第三章
    例2-11
    例2-10
    例2-8
    例2-9
    例2-7
  • 原文地址:https://www.cnblogs.com/tortoise512/p/15611102.html
Copyright © 2011-2022 走看看