| I am using CentOS with php, and mysql for web service, and sometimes my server is dead by unknown reason so I optimize mysql database and restart web server manually.
Following is the first my /etc/cron.hourly/optimze process for seamless service. But I found some error when following function is called. # Programmed 2012 by Chun Kang (Super Coder, kurapa@kurapa.com)
# useless log file deletion
rm -rf /var/log/*.2
rm -rf /var/log/*.3
rm -rf /var/log/*.4
rm -rf /var/log/*.5
rm -rf /var/log/httpd/*.2
rm -rf /var/log/httpd/*.3
rm -rf /var/log/httpd/*.4
rm -rf /var/log/httpd/*.5
# server instance restart
/etc/init.d/httpd restart
/etc/init.d/mysqld restart
# database optimization
mysqlcheck --auto-repair -u -p --all-databases
In order to optimize database, you need to change , and for suitable to your server. So I found another method to remove unnecessary restart for daemon as following. # Programmed 2012 by Chun Kang (Super Coder, kurapa@kurapa.com)
# useless log file deletion
rm -rf /var/log/*.2
rm -rf /var/log/*.3
rm -rf /var/log/*.4
rm -rf /var/log/*.5
rm -rf /var/log/httpd/*.2
rm -rf /var/log/httpd/*.3
rm -rf /var/log/httpd/*.4
rm -rf /var/log/httpd/*.5
curl http://kurapa.com > /tmp/_foo_com_check.html
RESULT_SIZE=($( stat -c %s /tmp/_foo_com_check.html))
if [ $RESULT_SIZE -gt 1024 ]; then
# server status is normal so nothing should do
echo "server_agnt: nothing should do";
else
# instance restart
/etc/init.d/mysqld restart
/etc/init.d/httpd restart
# database optimization
mysqlcheck --auto-repair -u -p --all-databases
fi
unlink /tmp/_foo_com_check.html |