标准后台程序kill 重启脚本.

详见附件.
#!/bin/bash
checktime=6
filterNum=5
proc_name=particularImgMain
i=0
while [ $i -lt $filterNum ]
do
        res=$(ps aux|grep $proc_name|grep -v grep)
        pid=$(echo $res |  awk '{print $2}')
kill $pid
while [ 1 ]
do
str=$(ps aux|grep $proc_name|grep $pid|grep -v grep)
if [ ! "$str" ]
then
echo "$pid killed successfully"
break
fi
        echo "wait kill $pid $i, sleep $checktime sec"
        sleep $checktime
done
        let "i=i+1"
done

猜你喜欢

转载自shixm.iteye.com/blog/1555327