Cron job to restart Apache every N hours Ubuntu 10.4
Using Ubuntu 10.4, and would like to restart Apache every hour (for example).
This is not optimal solution, but I inherited a mess of a server and in the short term (while we figure out the REAL problem) we would like to recycle Apache once per hour. This does not really have an effect on our users as the site is mostly read only.
I'm a little weak in the CRON department, and would like to figure out a starting point.
Thanks in advance for your help!
-mxadmin
8 Replies
crontab -e
then add the following line
0 * * * * * /etc/init/apache2 restart
Save the crontab and then run
restart cron
Once you've fixed your problem just remove that line and restart cron again.
crontab -e
and adding the following line
0 * * * * /etc/init.d/apache2 restart
(or you could use the following syntax instead)
@hourly /etc/init.d/apache2 restart
and then save the file and exit the editor. To disable this, just run crontab -e again and remove the line you added, save, and exit.
It should not be necessary to restart cron.
(man 5 crontab will tell you about the available syntax and give examples.)
still be present in Ubuntu 10.04
I'd go back to some RPM based distro.