这是一个检测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服务器的运行状态,防止宕机