当前位置: > CentOS > CentOS运维 >

centos7监控httpd运行状态脚本

时间:2017-09-21 13:11来源:linux.it.net.cn 作者:IT
#!/bin/bash
# 获取运行状态
http=$(systemctl status httpd | grep Active | awk '{print $2}')
# 判断运行状态
if [ "$http" != "active" ];then
# 运行状态为失败时尝试重启并发出重启成功信息,如果运行失败发出失败警告!
systemctl restart httpd && echo "httpd Restart successfully" || echo "httpd Unable to restart"
exit 0
else
# 判断如果运行状态为正常发出正常信息
echo "httpd Normal operation"
exit 1
fi
------分隔线----------------------------


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容