Centos LAMP Restart Script
Posted by: Mike | Filed under: centos, drupal, lamp, linux
Here's a simple script to monitor a web app hosted on a Centos/Red Hat server for the "white screen of death" that you'll get if PHP runs out of memory or you get a fatal error with error display turned off. In the example below, the script is monitoring Drupal by checking the user login screen:
You'll want to add an entry to your /etc/crontab file similar to the one below, assuming we've named the script "lamp_test.sh":
You'll likely want to add logging of restarts as well.
#!/bin/bash wget -q http://<your site>/user -O /tmp/apache_test.html if [ -s /tmp/apache_test.html ]; then echo > /dev/null else /etc/rc.d/init.d/mysqld restart /usr/sbin/apachectl restart fi
00,05,10,15,20,25,30,35,40,45,50,55 * * * * root <path to your test script>/lamp_test.sh