waterye

检测进程是否存在

#!/bin/sh

while :
do
    PID=`cat /home/pid.file`
    RUN_FLAG=`ps -p $PID | awk -v var=$PID '$1==var { print "1" }'`
   
    if [ -n "$RUN_FLAG" ] # string is not "null".
      then
        echo 'running' # running
      else
        echo 'kao' # restart process
    fi
   
    sleep 60 # 1 minute
done

posted on 2007-07-09 21:47 waterye 阅读(1075) 评论(0)  编辑  收藏 所属分类: Linux


只有注册用户登录后才能发表评论。


网站导航: