码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2016-06-03 14:20:50      阅读:171      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!