Your Proxy IP is:

Script to check status of Apache Mysql and restart if failed

Here's a script to check the status of Apache and MySQL and restart it if its failed:

dt=`date %y-%m-%d---%H:%M:%S`

st=`service apache2 status`

if [[ $st == *NOT* ]]


sf="Apache Service FAILED"

echo $dt $sf >> /opt/scripts/status.log

service apache2 stop

service apache2 start


sst=`netstat -lpn | grep 3306`

if [[ $sst == "" ]]


ssf="Mysql Service Failed"

echo $dt $ssf >> /opt/scripts/status.log

service mysql start


The script then runs via cron and logs events into a log file it the service had failed.