Recently don't know why blogs are always somehow hanging off,
Restarting Apache is good, and I'm too lazy to study exactly where it went wrong.
Just need to manually ssh up to restart Apache every time, a bit of trouble.
And sometimes it hangs in the night, and one night the blog is inaccessible.
Finally unbearable, wrote a script to do this thing, the code is as follows:
#!/bin/shif (wget--timeout=5 -Q--spider http://leonax.net/) " OK " else/etc/init.d/"httpd restarted"fi
The principle is simple, is to try to visit the blog (the third line),
If there is any problem, restart Apache (line seventh).
The wget parameter –spider means just a visit and does not download the content.
If you like, you can also add an e-mail code to the Else
The Apache error log sent directly to the mail, convenient analysis, but I do not bother to do.
Then save the code as check_apache.sh and add it to the crontab:
*/5 * * * */var/www/check_apache.sh
Where */5 says to run check_apache.sh every 5 minutes.
Note that you should use sudo when opening crontab, because it requires sudo permissions to restart Apache.
Reprinted from: http://leonax.net/c/product/software/apache/
Automatic restart of Apache in case of failure