6

The web is full of suggestions how to disable mailing in cron like asked here stop linux from emailing me cron errors?. Is there really no global config flag I can set to disable mailing in cron for all users and all commands. I really don't want to tell all users you have to add

MAILTO=""

or

<command> > /dev/null 2>&1

to your crontab.

Laoneo
  • 274
  • 1
  • 3
  • 13
  • 1
    this is very common way to do, you can also disable `sendmail`|`postfix`. – alexus Mar 14 '14 at 15:09
  • 1
    In my experience, disabling sendmail causes the mail to build up in the queue. Not sending mail in the first place is the most ideal solution. – Chris Mendez Jul 22 '15 at 15:52
  • for centos this is the way to do it: https://serverfault.com/questions/871039/centos-7-how-to-fully-disable-cron-email-generation – Pavel Niedoba Sep 05 '17 at 08:51

1 Answers1

9

according to the man page can disable cron mail by adding -m off to the daemon args

   -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.
Gryphius
  • 2,720
  • 1
  • 19
  • 19
  • Nice one. On Ubuntu where can i define the daemon args? – Laoneo Mar 14 '14 at 15:09
  • I'm no ubuntu/upstart expert. I guess you'd have to change in `/etc/init/cron.conf` or add in `/etc/init/cron.override`, see init [manpage](http://manpages.ubuntu.com/manpages/saucy/man5/init.5.html) – Gryphius Mar 14 '14 at 15:32
  • 3
    Ubuntu uses vixiecron by default which does not have this option, unfortunately I am also unsure about what is the actual solution for this in ubuntu, anyone? – Onitlikesonic Mar 17 '14 at 12:24
  • @Onitlikesonic As far as I'm aware there's no way to globally disable cron emails in Vixie cron - you may be out of luck unless you're willing to change your cron daemon (which is probably the easiest solution)... – voretaq7 Mar 18 '14 at 16:46
  • 1
    @Onitlikesonic See https://askubuntu.com/questions/435454/vixiecron-doesnt-allow-disabling-of-emails-how-can-i-disable-cron-emails-globa – augurar Sep 20 '17 at 20:49