您的位置:首页 > 理论基础 > 计算机网络

Apache httpd进程监控,自动重启httpd服务shell

2018-02-01 00:00 477 查看
摘要: Apache httpd进程监控shell,让服务永远在线

#!/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Apache httpd CentOS