现在的位置: 首页 > 综合 > 正文

检查apache服务器是否正在运行的脚本

2014年09月17日 ⁄ 综合 ⁄ 共 229字 ⁄ 字号 评论关闭

这是一个检测apache服务器是否正在运行的脚本,如果没有运行,则启动apache;

#/bin/sh
	web=$(pgrep apache)
        echo "web is $web"
	if [ "$web" != "" ]
	then
 		echo "the apache is running."
	else
		echo "the apache is not running."
              	/etc/init.d/apache2 start
	fi

PS:

可以和crontab一起用,每隔一段时间检查下apache服务器的运行状态,防止宕机


抱歉!评论已关闭.