2 04 2009

重启apache的bash脚本

bigCat Posted in Linux - for Comments = 2
INFO=`netstat -ln | grep -P ":80"`
DATE=`date`
if [ "$INFO" == "" ]
then
/etc/init.d/httpd restart
echo "$DATE shit happens" >> /var/log/httprestart.log
ps aux | mail -s mt17down httprestart@ooxx.me
else
echo "$DATE pass" >> /var/log/httprestart.log
fi

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

  1. whatUwant says:

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

  2. bigCat says:

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

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