Controlling Email Sent by Cron

So I had to create a cron job to do a task re networking issue. Works fine, but no matter what I do, the cron insists on sending an email. I have added MAILTO=“” and the command gets ignored. I modified the crond file to add CRONDARGS= -s -m off
None of these changes work. No idea why they don’t work.
Thanks

The email will only get sent if any output is produced, so:

command >/dev/null 2>&1

should suppress the email.

All this will only work if is cron, rather than the command, that is sending the email.

Well, I tried adding the command. The email still keeps coming. This is where it comes from:

Received: from pbx (pbx.XXXXX.com [XXX.XXX.XXX.XXX])
by mail.XXXXX.com with ESMTP (TLS encrypted); Tue, 23 Aug 2022 03:17:03 -0500
Received: by pbx (Postfix, from userid 0)
id DXXXXXXX; Tue, 23 Aug 2022 03:17:02 -0500 (CDT)
From: Anacron [email protected]
To: [email protected]
Content-Type: text/plain; charset=“UTF-8”
Subject: Anacron job ‘cron.daily’ on pbx.XXXXX.com

The user address the email is sent to does not exist.

I didn’t give you a command. I gave you a modification of the command that you are already running, namely suffixing each of them with “>/dev/null 2>&1

The default address that cron sends to is that of owner of the crontab, as a local user (no @ or domain). The email submission system is appending the domain of the local machine, rather than delivering it locally, to the file /var/spool/mail/root

Thanks. It is a just small annoyance, that I am going to disregard at this point. Set my email server to discard the emails. {I had upgrade email system so starting looking at logs to make sure upgrade was fine, and found all these cron job messages.] But you are right, that cron job is trying to write to an empty local file, and that email submission system is rewriting whatever I tell it to send to using MAILTO. And even when I add the suffice language it is ignored. Restarted the service, but at weekend will reboot everything. Perhaps I did not write changes as I thought I did, or didn’t have write permission, etc. But, my email system defers the bogus messages for a couple cycles then deletes them.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.