判断本机的80端口是否开启着,如果开启着什么都不做,如果发现端口不存在,那么重启一下httpd服务,并发邮件通知你自己。

#! /bin/bash
mail=123@123.com
if netstat -lnp |grep ':80' |grep -q 'LISTEN'; then
exit
else
/usr/local/apache2/bin/apachectl restart >/dev/null 2> /dev/null
python mail.py $mail "check_80" "The 80 port is down."
n=`ps aux |grep httpd|grep -cv grep`
if [ $n -eq 0 ]; then
/usr/local/apache2/bin/apachectl start 2>/tmp/apache_start.err
fi
if [ -s /tmp/apache_start.err ]; then
python mail.py $mail 'apache_start_error' `cat /tmp/apache_start.err`
fi
fi

相关文章:

  • 2021-04-06
  • 2021-11-25
  • 2021-08-30
  • 2021-09-23
  • 2021-11-30
  • 2021-11-30
  • 2021-09-15
  • 2021-08-20
猜你喜欢
  • 2021-10-12
  • 2022-12-23
  • 2021-10-07
  • 2021-11-30
  • 2021-05-09
  • 2021-07-02
  • 2021-04-05
相关资源
相似解决方案