Arhiv za november 22, 2017

visoke obremenitve,Samodejni ponovni zagon mysql,apache

#!/bin / sh
# crontab: */3 * * * * /koren / loadavg_restart_apache.sh >> /Wise / Ljudje / Ristart_apacheklog
sinhronizacijo
sinhronizacijo
echo 3 > /proc / sys / vm / drop_caches
TOP_SYS_LOAD_NUM = 5
SYS_LOAD_NUM = 'uptime | awk '{print $(NF-2)}’ | sed 's /, //' '
echo $(datum +”%Y-% m-% d”) `uptime`
če [ `echo “$TOP_SYS_LOAD_NUM < $SYS_LOAD_NUM”|bc` -eq 1 ]
potem
sinhronizacijo
echo “#0#” $(datum +”%Y-% m-% d% H:%M:%S”) “pkill httpd” `Ps -ef | grep httpd | wc -l`
echo “#0#” $(datum +”%Y-% m-% d% H:%M:%S”) “pkill mysql” `Ps -ef | grep mysql | wc -l`
Storitev stop httpd
Storitev stop mysql
spanje 8
pkill httpd
pkill mysql

spanje 8
za iv 1 2 3
storiti
če [ `Pgrep mysql | -V WC -l` 0 ]
potem
/sbin/service mysql start

spanje 30
echo “#1#” $(datum +”%Y-% m-% d% H:%M:%S”) “start mysql” `Ps -ef | grep mysql | wc -l`

fi

če [ `pgrep httpd | -V WC -l` 0 ]
potem

service httpd start

service wdapache start

spanje 30

echo “#1#” $(datum +”%Y-% m-% d% H:%M:%S”) “start httpd” `Ps -ef | grep httpd | wc -l`
fi

Končano
else
če [ `Pgrep mysql | -V WC -l` 0 ]
potem
/sbin/service mysql start

spanje 30
echo “#2#” $(datum +”%Y-% m-% d% H:%M:%S”) “start mysql” `Ps -ef | grep mysql | wc -l`

fi

če [ `pgrep httpd | -V WC -l` 0 ]
potem

service httpd start

 

spanje 30

echo “#2#” $(datum +”%Y-% m-% d% H:%M:%S”) “start httpd” `Ps -ef | grep httpd | wc -l`
fi

fi

将以上文件,保存在 /root/loadavg_restart_apa_my.sh

然后在

crontab -e

添加

*/3 * * * * /koren / loadavg_restart_apa_my.sh >> /Wise / Ljudje / Ristart_ap_mayklog

*/3 ***** Predstavlja tri minute,/root / loadavg_restart_apa_my.sh lahko prilagodite。

Komentarji