# ! /bin/sh
basepath=$(cd `dirname $0`; pwd)
while true
do
procnum=`ps -ef|grep "服务名称"|grep -v grep|wc -l`
if [ $procnum -eq 0 ]
then
启动命令
echo `date +%Y-%m-%d` `date +%H:%M:%S` "restart 服务" >>$basepath/shell.log
fi
sleep 1
done
后台执行 nohup ./shell.sh &