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. --- 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 "hns1 at iinet.net.au" <hns1 at iinet.net.au> Reply-To: CentOS mailing list <centos at centos.org> Date: Wednesday, July 19, 2017 at 4:13 PM To: CentOS mailing list <centos at centos.org> Subject: Re: [CentOS] Cron sending to root after changing MAILTO ----- Original Message ----- From: "CentOS mailing list" To:"CentOS mailing list" Cc: Sent:Wed, 19 Jul 2017 20:46:21 +0000 Subject:[CentOS] Cron sending to root after changing MAILTO I am running CentOS 7 on an outbound gateway server running Postfix. I have a couple of cron jobs I was expecting to see in my email that never showed up. It turns out that they were delivered to root, which is restricted on our exchange server, instead of the address I defined. Please help. The quick fix for such issues is to put a .forward file in the /root folder containing your target e-mail address, ecssupport at csusb.edu _______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos
On Wed, 2017-07-19 at 23:31 +0000, Chad Cordero wrote:> It?s being rejected before it even reaches the mailboxIs it rejected because of the recipient address or the sender address? In your log message, I noticed this sender address: from=<root at csusb.edu> In case your mail server is rejecting it because of the sender address you can do this: create a file /etc/postfix/sender_canonical with contents like: root _valid_sender_address_ Then run: postmap /etc/postfix/sender_canonical -- Ian
> 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?
On Wed, 2017-07-19 at 23:31 +0000, Chad Cordero wrote:> 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. >Have you restarted crond after you made the changes? P.
> Date: Thursday, July 20, 2017 09:02:02 +0100 > From: Pete Biggs <pete at biggs.org.uk> > > On Wed, 2017-07-19 at 23:31 +0000, Chad Cordero wrote: >> 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. >> > Have you restarted crond after you made the changes? > > P.An explicit restart of crond shouldn't be needed as it should automatically reload the changed file the next minute, e.g.: Jul 20 01:44:01 ... crond[1464]: (*system*) RELOAD (/etc/crontab) but if that's not being logged, then then that might indicate an issue with crond.
> 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".]