> Date: Thursday, July 20, 2017 02:25:52 +0000 > From: Richard <lists-centos at listmail.innovate.net> > >> Date: Wednesday, July 19, 2017 23:31:10 +0000 >> From: Chad Cordero <ccordero at csusb.edu> >> >> It?s being rejected before it even reaches the mailbox, so >> forwarding won?t work.? Crond should really be using the MAILTO >> variable and it?s not. >> > > In my testing, this worked as advertised. Changing the "MAILTO=" in > /etc/crontab from the default "root" to either a local username or a > remote address resulted in the crontab messages being delivered to > the desired mailboxes. I think I'd put a test command into the > crontab and watch the logs to see what might be going on -- > including making certain that the crontab is reloading correctly > after changing the "mailto" value. > > Separately, but related, did you run newaliases or postalias after > you added the entry to "root:" in /etc/aliases? >Re-reading earlier messages, are the commands in question being invoked out of /etc/crontab, /etc/cron.daily, etc. or user-level crontabs? 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. --- Chad Cordero Information Technology Consultant Enterprise & Cloud Services Information Technology Services California State University, San Bernardino 5500 University Pkwy San Bernardino, CA 92407-2393 Main Line: 909/537-7677 Direct Line: 909/537-7281 Fax: 909/537-7141 http://support.csusb.edu/ --- Disclaimer: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. From: CentOS <centos-bounces at centos.org> on behalf of Richard <lists-centos at listmail.innovate.net> Reply-To: CentOS mailing list <centos at centos.org> Date: Thursday, July 20, 2017 at 6:54 AM To: CentOS mailing list <centos at centos.org> Subject: Re: [CentOS] Cron sending to root after changing MAILTO Date: Thursday, July 20, 2017 02:25:52 +0000 From: Richard <lists-centos at listmail.innovate.net> Date: Wednesday, July 19, 2017 23:31:10 +0000 From: Chad Cordero <ccordero at csusb.edu> It?s being rejected before it even reaches the mailbox, so forwarding won?t work. Crond should really be using the MAILTO variable and it?s not. In my testing, this worked as advertised. Changing the "MAILTO=" in /etc/crontab from the default "root" to either a local username or a remote address resulted in the crontab messages being delivered to the desired mailboxes. I think I'd put a test command into the crontab and watch the logs to see what might be going on -- including making certain that the crontab is reloading correctly after changing the "mailto" value. Separately, but related, did you run newaliases or postalias after you added the entry to "root:" in /etc/aliases? Re-reading earlier messages, are the commands in question being invoked out of /etc/crontab, /etc/cron.daily, etc. or user-level crontabs? 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".] _______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos
> 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.]
On Thu, July 20, 2017 8:54 am, Richard wrote:> >> Date: Thursday, July 20, 2017 02:25:52 +0000 >> From: Richard <lists-centos at listmail.innovate.net> >> >>> Date: Wednesday, July 19, 2017 23:31:10 +0000 >>> From: Chad Cordero <ccordero at csusb.edu> >>> >>> It???s being rejected before it even reaches the mailbox, so >>> forwarding won???t work.?? Crond should really be using the MAILTO >>> variable and it???s not. >>> >> >> In my testing, this worked as advertised. Changing the "MAILTO=" in >> /etc/crontab from the default "root" to either a local username or a >> remote address resulted in the crontab messages being delivered to >> the desired mailboxes. I think I'd put a test command into the >> crontab and watch the logs to see what might be going on -- >> including making certain that the crontab is reloading correctly >> after changing the "mailto" value. >> >> Separately, but related, did you run newaliases or postalias after >> you added the entry to "root:" in /etc/aliases? >> > > Re-reading earlier messages, are the commands in question being > invoked out of /etc/crontab, /etc/cron.daily, etc. or user-level > crontabs? > > 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".]There are many things one can do as far as root mail is concerned... The best in my book is the smallest, easiest, and resolving everything. Which is (as suggested already I bet more than once): add to the end of /etc/aliases the line root: person at some.mail.server ( and don't forget to: newaliases && postfix reload ) where "person at some.mail.server" is real e-mail address that works, of a real person who does read mail at that address, and ideally there should be no spam/virus etc filtering on that. There should be person who should ideally read everything that ends up sent to root! Note, that with postfix as MX making alias (usually to non-privileged user on the same box; ideally that shouldn't be sent over internet) for root's email is mandatory. Root account should not receive e-mail for security reasons. However, e-mail sent by system tasks is to be checked by sysadmin. Also: there are several e-mail accounts that should exists and accept mail; on MX box: postmaster is one of them. If that MX is responsible MX for domain, there also should be hostmater, security, and abuse. (Please, read RFCs for all details, too much to cite, and I definitely will miss something ;-) All of these by default are aliased to root, so root's e-mail has to be accepted and all of it should be delivered to a person (or persons). I hope, this helps. Valeri ++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++
Alexander Dalloz
2017-Jul-20 17:30 UTC
[CentOS] Cron sending to root after changing MAILTO
Am 20.07.2017 um 16:57 schrieb Valeri Galtsev:> ( and don't forget to: newaliases && postfix reload )There is no need to reload Postfix after aliases_db changes and a newaliases. Same applies for other hashed maps refreshed by postmap. Alexander