判断Apache是否启动
#!/bin/bash
#Desc: 判断Apache是否启动
#Author: Beetester
#使用nmap命令扫描服务器,并获取Apache服务的状态并赋值给port
port=$(nmap -sT 192.168.2.249 | grep tcp | grep http | awk ‘{print $2}’)
if [ “$port” == “open” ]
then
echo “$(date) httpd is ok!” >> /tmp/autostart-acc.log
else
/etc/rc.d/init.d/httpd start &> /dev/null
echo “$(date) restart httpd!” >> /tmp/autostart-acc.log
fi