美文网首页
监控服务进程退出自启动

监控服务进程退出自启动

作者: GodfansMa | 来源:发表于2019-03-15 10:44 被阅读0次

    参考:https://blog.csdn.net/ljxfblog/article/details/40362229?utm_source=blogxgwz9

    1.编写脚本
    #! /bin/sh
    
    proc_name="test"        #进程名
    
    proc_num()                      #查询进程数量
    {
        num=`ps -ef | grep $proc_name | grep -v grep | wc -l`
        return $num
    }
    
    proc_num
    number=$?                       #获取进程数量
    if [ $number -eq 0 ]            #如果进程数量为0
    then                            #重新启动服务器,或者扩展其它内容。
        cd /home/me/go/src/test; ./test -c 1
    fi
    
    2. sudo vim /ect/crontab 在最后加入
    */3 *  * * * me /home/me/Desktop/db_back/monitor.sh
    

    相关文章

      网友评论

          本文标题:监控服务进程退出自启动

          本文链接:https://www.haomeiwen.com/subject/wrflmqtx.html