#!/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) |