2 04 2009

重启apache的bash脚本

bigCat Posted in Linux - for Comments = 2
INFO=`netstat -ln | grep -P ":80"`\r\nDATE=`date`\r\nif [ "$INFO" == "" ]\r\nthen\r\n/etc/init.d/httpd restart\r\necho "$DATE shit happens" >> /var/log/httprestart.log\r\nps aux | mail -s mt17down httprestart@ooxx.me\r\nelse\r\necho "$DATE pass" >> /var/log/httprestart.log\r\nfi

\r\n\r\n\r\n\r\n

*/1 * * * * /root/httprestart.sh >/dev/null 2>&1

\r\n\r\n

  1. whatUwant says:

    求教:如果是返回500、502、504这种错误,$INFO=="" 吗?

  2. bigCat says:

    也是apache的返回码..只要80还活着,就不会空\r\n监控状态码可以模拟访问,提取文件头

Host: (miao) | Word: Press | Code: HTML5