#!/bin/sh
while [ 1 ]
do
magicServerId=`ps -ef | grep -F /home/wt/magicServerCommunicationTest/MagicServer.out|grep -v grep|awk '{print $2}'`
if [ $magicServerId ]
then
echo "/home/wt/magicServerCommunicationTest/MagicServer.out is running pid is" $magicServerId
else
nohup /home/wt/magicServerCommunicationTest/MagicServer.out &
fi
sleep 5
done
将此脚本命名为watchDog.sh,放到/etc/init.d/下,
若要开机自动跑此脚本
在/etc/rc.local中添加
/etc/init.d/watchDog.sh restart