5

Every time the cron runs there are some sendmail processes being created which take our machine to huge high loads. We have chased this problem down to cron and sendmail.

Adding MAILTO="" on top of the cron is a solution, piping each cron command to dev null is another solution but I need a global solution... some sort of configuration on cron or so.

Vixiecron DOES NOT have the following option which I believe it would fix my problems

-m     This option allows you to specify a shell command to use for sending Cron mail  output  instead  of
      using  sendmail(8)  This command must accept a fully formatted mail message (with headers) on stan‐
      dard input and send it as a mail message to the recipients specified in the mail headers.  Specify‐
      ing the string off (i.e., crond -m off) will disable the sending of mail.

So how can I globally disable cron emails completely?

Braiam
  • 69,112

1 Answers1

4

When it has to be vixie-cron adding MAILTO="" on top of the cron is the solution. There is no global method (all options are stored in the respective users crontab). This

cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists). The children copies of cron running these processes have their name coerced to uppercase, as will be seen in the syslog and ps output.

has no additional configuration so is executed always (it is also possible to kill the sending of mails by adding >/dev/null 2>&1 or &>/dev/null to the command itself; but that would be more work then editing all crontabs).

The link also states:

Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly.

I see 3 possible options:

  • My preferred method would to edit all the crontabs with crontab -e.

  • use another cron that does have a method for globally setting MAILTO (which cron and how to do this is for another question ;) )

  • ignore the warning and edit all files from commandline with a for/next loop. I read that as "you can if you really really really really really really want to.". Mind the remarks in these 2 topics about this: ubuntuforums and serverfault. As far as I can tell the only problem you face (if done correctly!) is that your change gets overwritten if someone does use crontab -e. But if you all agree that if someone does change a crontab with crontab -e that they also HAVE to include the MAILTO='' that concern should be taken care of (since the change you made is overwritten by the new crontab but that one also includes your change).

Rinzwind
  • 309,379