Re: cron and MAILTO

On Mon, Dec 19, 2011 at 05:32:44AM GMT, T o n g wrote:
Let me explain with an example.

Say I have a file under /etc/cron.d/ with the following entry:

42 4 1 * * user1 echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * user2 echo "This command is run hourly on the 19th of July"

Usually, when the jobs do get fired up, each user receives the
corresponding message in their email.

Now, if I put 'MAILTO=user3' at the top of the file, what will happen?

It would've been quicker if you had tested it yourself or RTFM.

% man 5 crontab

In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO
if it has any reason to send mail as a result of running commands in
``this'' crontab.
If MAILTO is defined (and non-empty), mail is sent to the user so
named. MAILTO may also be used to direct mail to multiple recipients
by separating recipient users with a comma. If MAILTO is defined but
empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to
the owner of the crontab.


To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx

Relevant Pages

  • Re: cron problems
    ... Why is cron looking for sendmail? ... "man 5 crontab" states: ... If MAILTO is defined, ... However I can't think of a good reason why a sysadmin would want to configure ...
  • CRON wont send mail anymore.
    ... My problem is that cron won't send out mail, ... what I set the MAILTO-variable to in my crontab. ... appears not to supply the target email as specified in MAILTO. ... An error message could look like this: ...
  • RE: Why this crontab does not work?
    ... Why this crontab does not work? ... apt-get upgrade -d ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
  • Re: Disable cron emails for certain jobs
    ... If I make MAILTO= the first line in the job to disable email [as per man ... crontab], it doesn't parse the crontab, ... Is this a bug in Debian Testing's current cron, ... the cron jobs. ...
  • Re: Postgres
    ... see a reason why other users should access /root) ... chmod 600 /root/.pgpass ... >> I'm trying to write a backup script for postgres and us a crontab on it. ... > To unsubscribe, ...