Cron - restart apache

werwin01

Verified User
Joined
Aug 2, 2004
Messages
34
I need some help creating a cron that will restart apache every hour.

*/60 * * * * root service httpd restart

If I put that in /etc/crontab would it restart apache every 60 minutes?
 
It should, although why do you want to restart apache every hour?

Also is would be better to use this

* */1 * * *
 
Last edited:
Well, probably not every hour.

There are times when apache loads get very high, and start to eat up the CPU and cause high server loads. I don't know what causes this, but restarting apache always works to stop the problem. Maybe restarting it every day, or if possible, is server loads reach a certain level, then restarting apache?
 
There is a domain monitoring tool in the 3rd party forums which will collect cpu usage stats for all domains, maybe its one of your users scripts?

Only way I can think of at the moment to restart if apache server load goes over a set limit is to setup the cron to run a php or perl script every minute or so which would get and parse the server load and then decide whether or not to restart apache. Although I suggest looking for users scripts that could possible be causing this with that domain monitoring tool.
 
I'm running one a gnutella web cache, which might be the problem.

14938 blacknex 21 0 0 0 0 Z 4.7 0.0 0:00 0 perlgcache.cgi <defunct>

The CPU is just 4.7 for it though, and it's not running under the actual apache process name, and the problem occurs under the apache name.

Thanks for your help.
 
Back
Top