首页 > 代码库 > 监控httpd服务一旦发现关闭从新开启每十分钟检测一次

监控httpd服务一旦发现关闭从新开启每十分钟检测一次

#!/bin/bash
#auther:acf
#function:monitoring service of httpd
[root@my-cmp Desktop]#cat b.sh
a=`ps -A|grep httpd |grep -v grep|awk ‘{print $4}‘|wc -l`
if [ $a != 0 ];then
echo "httpd is running..."
else echo "httpd was stoped,now httpd is starting..."
/etc/init.d/httpd start
fi
===

===接下来将其写入计划任务中
[root@my-cmp Desktop]# crontab -e
*/10 * * * * /bin/bash /root/Desktop/b.sh

监控httpd服务一旦发现关闭从新开启每十分钟检测一次