#!/bin/bash
# Apache httpd进程监控shell
# 如果你在使用RHEL / CentOS / Fedora Linux,使用这个重启命令
RESTART="/sbin/service httpd restart"
# 如果你在使用 Debian / Ubuntu Linux,把上面的RHEL的注释掉,换用这个
#RESTART="/etc/init.d/apache2 restart"
#path to pgrep command
PGREP="/usr/bin/pgrep"
# Httpd daemon name,
# Under RHEL/CentOS/Fedora it is httpd
# Under Debian 4.x it is apache2
HTTPD="httpd"
# Debian / Ubuntu Linux 下进程名是apache2
#HTTPD="apache2"
# find httpd pid
$PGREP ${HTTPD}
if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
fi