#!/bin/bash
current_time="`date +%Y-%m-%d_%H:%M:%S`"
check_port(){
netstat -tlpn | grep "\b$1\b"
}
#判断端口是否存在
if check_port 80
then
echo $current_time": nginx is running" >> /data/shell/nginx.log
else
echo $current_time": nginx is stop" >> /data/shell/nginx.log
#启动mq服务
/sbin/service nginx start
echo $current_time": nginx is restarting" >> /data/shell/nginx.log
fi