Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just want someone to confirm this is the correct cron configuration to have the server restart Apache every Sunday night. I have never done a cron command which had a space in it, so want to make sure it's correct.

0 3 * * 0 /bin/sh /usr/sbin/apachectl restart
share|improve this question
up vote 3 down vote accepted

To begin with, why are you restarting Apache on a cron - furthermore why with a SIGKILL (restart) statement rather than SIGHUP (graceful)

This is a much "friendlier" means of restarting Apache, so that you don't kill off existing sessions.

/usr/sbin/apachectl graceful

Your cron will kill and start Apache at 3am on Sunday.

Bear in mind, different OS'es have different possible notation for Sunday on a crontab - it could be any of:

0 3 * * sun
0 3 * * 0
0 3 * * 7

And if you don't want to be harassed via email, you can discard STERR and STOUT by appending this to the end of your command

> /dev/null 2>&1
share|improve this answer
Thanks. I know it's not the best thing but there is some Apache connection which keeps crashing the server, so hoping this is a temp fix until we can migrate off. – Louis W Jun 27 '12 at 17:58
A better solution (short of fixing the root cause) would be to use a watchdog application like monit – Ben Lessani - Sonassi Jun 27 '12 at 18:46

Looks fine to me, I guess. You might want to redirect output somewhere, even if it's just /dev/null. Otherwise cron will start trying to email you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.