Si desean programar un cron para el reinicio automático de apache en caso de caida, podrían hacerlo así:
1.- Contenido de apache_check.sh que deberían situarlo en /root/scripts
checkapache=`ps ax | grep -v grep | grep -c httpd`
if [ $checkapache == 0 ]
then
/etc/init.d/httpd restart
echo “`/bin/date` [APACHE DEAD]” >> /var/log/apachecrash.log
echo “APACHE CAIDO Y REINICIADO!” | mail -s “Server Alert: `/bin/hostname`” 24×7@hostigal.com
exit
else
echo “`/bin/date` [APACHE OK]” >> /var/log/apachecrash.log
exit
fi
2.- Crear un cron del tipo
*/1 * * * * /root/scripts/apache_check.sh
with
crontab -e
3.- Verificar el funcionamiento en los logs
tail -f /var/log/apachecrash.log