Categories
BEST PHP CODE PHP

How to setup a CRON JOB for apache/httpd to restart automatically ?


Very helpful website top figure out crontab sequence

https://crontab.guru/#0_0_*_*_*

Every 30 minutes 

/etc/crontab

  */30  *  *  *  *       root /etc/init.d/httpd restart > /dev/null 2>&1

  */30  *  *  *  *       root /etc/init.d/mysql restart > /dev/null 2>&1

Every hour

/etc/crontab

  0  *  *  *  *       root /etc/init.d/httpd restart > /dev/null 2>&1

Every minute

/etc/crontab

  *  *  *  *  *       root /etc/init.d/httpd restart > /dev/null 2>&1

Check logs 

tail n- 200  /var/log/cron

tail n- 200  /var/log/messages

Plus link here regarding dev/null 2>&1

————————————————————————

Leave a Reply