[CentOS] Cron sending to root after changing MAILTO

Thu Jul 20 14:47:10 UTC 2017
Richard <lists-centos at listmail.innovate.net>


> Date: Thursday, July 20, 2017 14:26:49 +0000
> From: Chad Cordero <ccordero at csusb.edu>
> 
>> From: CentOS <centos-bounces at centos.org> on behalf of Richard
>> Date: Thursday, July 20, 2017 at 6:54 AM
>> 
>> The "mailto" value is crontab file specific, so setting it in
>> /etc/crontab would only effect commands run from there (a file that
>> isn't used much any longer). As the /etc/cron.daily, etc. jobs are
>> now run from /etc/anacrontab you'd need to adjust the "mailto" in
>> that file for things run that way. If run from a user-level crontab
>> the "mailto" needs to be in that user's crontab file. [cron.hourly
>> is run out of /etc/cron.d/0hourly, not anacrontab, and has its own
>> "mailto".]
>>  

>
> Well, I feel silly.ᅠ There are three places MAILTO can affect
> crond: /etc/crontab, /etc/crond.d/0hourly, and /etc/anacrontab.ᅠ
> Once I set this in these 3 files, I started getting mail from
> crond.ᅠ Thank you all for your help.
> 

As I noted, the "mailto" is crontab specific (see: man -s5 crontab),
so where you need to change that value depends on the crontab the job
is invoked from. I believe that the /etc/crontab file is mostly
obsolete at this point, so I don't think changing the "mailto" there
has any real effect (except for jobs specifically put in there).

Note, some (generally) cron-invoked programs, e.g., logwatch, have
their own "mailto" settings, which will get used rather than what is
set in the crontab. You'll need to make script-specific adjustments
for these.

[please don't top post. turning off disclaimers that have no
relevance on list postings is also nice.]