首页 > 系统服务 > 详细

shell:监控进程运行状态并自动重启进程

时间:2016-06-03 14:20:07      阅读:192      评论:0      收藏:0      [点我收藏+]

 

#!/bin/sh

MAXRSTCOUNT=5;
PROCTOGO=/mnt/hgfs/code/test/show

#count is the counter of test started times
count=0

sys_reboot()
{
    echo "system is going to reboot";
    reboot;
}

main_loop()
{
    while :
    do
    #########################################
    ProStillRunning=$(ps -aux |grep "${PROCTOGO}" |grep -v "grep")
    if [ -z "$ProStillRunning" ]; then
        #start test
        chmod +x ${PROCTOGO}
        ${PROCTOGO}
    fi

    #the running times counter
    let count=count+1
    echo "test running times is $count"

    #wait for test stoping...
    sleep 3

    #########################################
    done
}

main_loop;

 

shell:监控进程运行状态并自动重启进程

原文:http://www.cnblogs.com/mylinux/p/5555926.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!