监控http进程所占内存过高重启httpd
#!/bin/sh # crontab usage: */2 * * * * /home/http_restart.sh >> /backup/restart_apache.log MIN_RAM=3200 FREE_RAM=`free -m| grep Mem|awk ‘{print $4}‘` echo $(date +"%y-%m-%d") `uptime` if [ `echo "$FREE_RAM < $MIN_RAM"|bc` -eq 1 ] then echo "#0#" $(date +"%y-%m-%d %H:%M:%S") "pkill httpd" `ps -ef | grep httpd | wc -l` /etc/init.d/httpd stop sleep 5 pkill httpd sleep 5 for i in 1 2 3 do if [ `pgrep httpd | wc -l` -le 0 ] then /etc/init.d/httpd start sleep 10 echo "#1#" $(date +"%y-%m-%d %H:%M:%S") "start httpd" `ps -ef | grep httpd | wc -l` fi done fi
本文出自 “我的运维之路” 博客,谢绝转载!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。