有没有检测负载的脚本自动重启APACHE
RT.. 负载超过 设置值 就重启APACHE 设定值不会导致VPS宕机 easy,楼下来。 楼下你行的 本帖最后由 nomaka 于 2013-6-9 22:46 编辑cat /proc/loadavg | awk '{print $1}'然后对比一下负载 大于则service httpd restart 写在 crontab ? #!/bin/sh
TOP_SYS_LOAD_NUM=设定负载值
SYS_LOAD_NUM=`uptime | awk '{print $(NF-2)}' | sed 's/,//'`
echo $(date +"%y-%m-%d") `uptime`
if [ `echo "$TOP_SYS_LOAD_NUM < $SYS_LOAD_NUM"|bc` -eq 1 ]
then
echo "#0#" $(date +"%y-%m-%d %H:%M:%S") "pkill httpd" `ps -ef | grep httpd | wc -l`
service httpd stop
pkill httpd
pkill php-cgi
sleep 10
for i in 1 2 3
do
if [ `pgrep httpd | wc -l` -le 0 ]
then
service httpd start
sleep 15
echo "#1#" $(date +"%y-%m-%d %H:%M:%S") "start httpd" `ps -ef | grep httpd | wc -l`
fi
done
else
if [ `pgrep httpd | wc -l` -le 0 ]
then
service httpd start
sleep 15
echo "#2#" $(date +"%y-%m-%d %H:%M:%S") "start httpd" `ps -ef | grep httpd | wc -l`
fi
fi
存成脚本,加入cron,每分钟一次跑。
页:
[1]