1 #! /bin/sh 2 3 while [ "1" == "1" ] 4 do 5 ps | grep -c "ps" > /var/tmp/tt 6 tmp=0 7 tmp=`awk '{print $0}' /var/tmp/tt` 8 if [ "$tmp" -gt "5" ];then 9 continue 10 else 11 reboot 12 fi 13 sleep 300 14 done
grep -c : 获取输出匹配行的计数
-gt :大于
1 #! /bin/sh 2 3 while [ "1" == "1" ] 4 do 5 ps | grep -c "ps" > /var/tmp/tt 6 tmp=0 7 tmp=`awk '{print $0}' /var/tmp/tt` 8 if [ "$tmp" -gt "5" ];then 9 continue 10 else 11 reboot 12 fi 13 sleep 300 14 done
grep -c : 获取输出匹配行的计数
-gt :大于