Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I believe that if there is any output from a cronjob it is mailed to the user who the job belongs to. I think you can also add something like MAILTO=vivek@nixcraft.in at the top of the cron file to change where the output is sent to.

Can I set an option so that cron jobs system-wide will be emailed to root instead of to the user who runs them? (i.e. so that I don't have to set this in each user's cron file)

share|improve this question
up vote 6 down vote accepted

Check /etc/crontab file and set MAILTO=root in there. Might also need in /etc/rc file

crond seems to accept MAILTO variable, I guess I am not sure completely but its worth a try changing the environment variable for crond before it is started. Like in /etc/sysconfig/crond or /etc/rc.d/init.d/crond script which sources the earlier file.


[centos@centos scripts]$ strings /usr/sbin/crond | grep -i mail
usage:  %s [-n] [-p] [-m <mail command>] [-x [
mailed %d byte%s of output but got status 0x%04x
[%ld] no more grandchildren--mail written?
mailcmd too long
[%ld] closing pipe to mail
share|improve this answer
Thanks very much! +1. Perhaps put the bottom part of your answer in a preformat / code format? – cwd Dec 16 '11 at 15:44

Put MAILTO=root in /etc/default/cron. This file contains cron's default settings.

man 5 crontab says,

If MAILTO is defined (and non-empty), mail is sent to the user so named.

Refer: http://man.cx/cron(1)#heading4

share|improve this answer
where? for each user's crontab file? – Nikhil Mulley Dec 16 '11 at 15:13
@Nikhil check my updated answer. – Sachin Divekar Dec 16 '11 at 15:25
it works for only the users' whose crontab has it. Will it work, if any of the users' do not have this variable set? I think @Cwd has asked specifically for a global setting that for all users. – Nikhil Mulley Dec 16 '11 at 15:29
@SachinDivekar -1 Nikhil is right. Also you edited my question and changed the meaning of it. The edited meaning does align with your answer, but this is not what i was asking. – cwd Dec 16 '11 at 15:43
@cwd sorry to edit your question. Is setting MAILTO in /etc/default/cron working for you? – Sachin Divekar Dec 16 '11 at 15:46

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.