(笔记)超实用的程序守护脚本,程序异常退出后自动重启程序

 

超实用的程序守护脚本,程序异常退出后自动重启程序

 

#!/bin/sh

while true

do

PIDS=`ps -ef |grep ./test |grep -v grep | awk '{print $2}'`

if [ "$PIDS" != "" ]; then
    echo $PIDS
    echo "wath process already started ! "
else
    ./test &
    echo "watch process has been restarted! "
fi

sleep 1

done

 

注:上述脚本中的./test即为程序名,用户可替换成自己的程序名称。

posted on 2024-03-11 08:37  tdyizhen1314  阅读(18)  评论(0编辑  收藏  举报

导航