Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

You would like to be notified via email of errors occurring while executing cron jobs.

I use CentOS and the file /etc/crontab for the configuration.

The first step I have done is:


and then I have appended this to each crontab entry:


That means this

24 4 * * * root /usr/sbin/ntpdate


24 4 * * * root /usr/sbin/ntpdate 2>/dev/null

In that way I should suppress the normal output and let error messages be sent.

I would like to know if you think what I have done is right and whether that has got any pitfall.

Thanks, Dan

share|improve this question
Based on the other users' feedback the correct way is: 24 4 * * * root /usr/sbin/ntpdate > /dev/null – dan Nov 10 '10 at 12:38
up vote 2 down vote accepted

Actually, I think you've done the exact reverse of what you wanted; you've suppressed the error messages (by sending STDERR to /dev/null) and will get only the normal output.


24 4 * * * root /usr/sbin/ntpdate > /dev/null

Better still, run ntpd; it's a much better way of keeping your clocks in sync than brute-force resetting them once a day.

share|improve this answer

IIRC cron emails the output of the command, so if you suppress errors (by throwing them at /dev/null) you'll receive ONLY command output and not errors. I found a nice script: cronic which wraps around commands in crontab and does exactly what you want: send emails on errors only.

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.