#!/bin/bash
now='date '+%Y-%m-%d %H:%M:%S''
#rm -rf /Afc/Run/watchDog.log
watchdogLog='/watchDog.log'
while (true)
do
now=`date '+%Y-%m-%d %H:%M:%S'`
count=`ps -ef|grep ProgermName1|grep -v grep`
if [ "$?" != "0" ];then
echo "$now process ProgermName1 not exists,will call ProgermName1!" > "$watchdogLog"
ProgermName1 &
exit
#else
#echo "$now process ProgermName1 is runing..."
fi
count=`ps -ef|grep ProgermName2|grep -v grep`
if [ "$?" != "0" ];then
echo "$now process ProgermName2 not exists,will restart ProgermName2!" > "$watchdogLog"
ProgermName2 &
#else
#echo "$now process ProgermName2 is runing..."
fi
sleep 5
done
linux shell写的看门狗脚本示例
最新推荐文章于 2024-04-07 17:41:32 发布