How do I to disable the email alert send by crontab? When my job is executed and the jobs cannot run normally it will sent an email to root. Why do I receive e-mails to my root account from cron? How can I prevent this? How can I disable email alert sent by cron jobs on a Linux or Unix-like systems?

The crontab command is used to maintain crontab files for individual users. By default the output of a command or a script (if any produced), will be email to your local email account. To stop receiving email output from crontab you need to append following strings at the end of crontab entry.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux or Unix OS
Est. reading time 2 minutes

Cron job prevent the sending of errors and output

To prevent the sending of errors and output, add any one of the following at the end of the line for each cron job to redirect output to /dev/null.
>/dev/null 2>&1
> /dev/null
> /dev/null 2>&1 || true
## send cron output to a log file ##
> /var/log/ 2>&1

This will prevent mail command spam when you type the mail command:
$ mail
Disable eMail Alert By Crontab on Linux and Unix to avoid mail spam

Cron job example to disable the email alert

Edit/Open your cron jobs, enter:
$ crontab -e
Append string >/dev/null 2>&1 to stop mail alert:

0 1 5 10 * /path/to/ >/dev/null 2>&1


0 1 5 10 * /path/to/ > /dev/null


0 * * * * /path/to/command arg1 > /dev/null 2>&1 || true

In this example, just redirect output to /dev/null only:
0 30 * * * /root/bin/ > /dev/null
We can use the following syntax when using bash to redirect both stdout and stderr:
1 30 * * * /root/bin/xyz-job &> /path/to/
## Append instead of overwriting the log file ##
1 30 * * * /root/bin/xyz-job &>> /path/to/
2 45 * * * /root/bin/foo-job &> /dev/null

Save and close the file. See redirect STDOUT and STDERR to null and “BASH Shell Redirect stderr To stdout ( redirect stderr to a File )” to suppress output for more information

Set MAILTO variable to stop cron daemon from sending email

Another option is to set MAILTO="" variable at the start of your crontab file or shell script. This will also disable email alert. Edit/Open your cron jobs:
$ crontab -e
At the top of the file, enter:
Of course we can redirect email too provided that email server such as Postfix configured:
Save and close the file. We can mix them as per our needs. For example:

## send email to backup team #
@daily /scripts/ 

## send email to RAID/storage/san/nas admin ##
* 45 * * * /scripts/ 

Another example:

## NO EMAIL ##
@weekly /scripts/containers-backup  >/dev/null 2>&1

## Send email ##
@daily /scripts/ 

## Disable email alert ##
@monthly /path/to/script/ > /var/log/monthly.log

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 46 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
46 comments… add one
  • Renish Ladani Aug 2, 2007 @ 13:57

    I tried above thing and it works on my server

  • Henrik Johansen Aug 3, 2007 @ 8:36

    Setting MAILTO="" in your crontab disables the sending of emails aswell.

  • Anand Sharma Aug 30, 2007 @ 7:52

    If your crontab has huge number of scripts to run it would be cumbersome to append >/dev/numm 2>&1 to each line. Like I have 369 scripts in my crontab. So I find it better to have the MAILTO=”” line at the start of my crontab instead.

    • kthx Aug 3, 2011 @ 4:01

      Hahaha just stop there for a while lol….

    • Kevin Aug 19, 2015 @ 16:49

      Holy cow. That is so many scripts for a crontab…

  • Gopal Jan 25, 2008 @ 9:26

    But if you have so many cron jobs and you want disable mail alert for a few of them, while other jobs needs a mail alert, then &>/dev/null would be the best choice.


  • Prolific Programmer Feb 1, 2008 @ 14:09

    For the csh scripts, at least on every system I have access to, to redirect stderr, you need to put >& /dev/null after the command, not &> as indicated by the note.

  • Matt Balloon Mar 7, 2008 @ 15:23

    I used your tip for my openads installation, thanks, I think cronjobs are pretty complicated things

  • Phil Oct 12, 2008 @ 12:10

    If you want the crontab to run daily, weekley, monthly etc.. a good shortcut is to use the variables

    @daily, @weekley etc…

    It saves you accidently missing out a * and getting thousands of emails by mistake

    for a full list of them

  • Sebastián Perrone Dec 10, 2008 @ 17:32

    I try MAILTO environment var and work ok. Thanks for help !

  • slowpoison Jun 22, 2009 @ 20:58

    Is it MAILTO or EMAILTO?
    Only MAILTO worked for me. I think EMAILTO is wrong.

  • 🐧 nixCraft Jun 22, 2009 @ 21:38

    @ slowpoison

    Thanks for the heads-up.

  • edward baddouh Aug 10, 2009 @ 13:27

    It’ll be better if you redirect only the std output to /dev/null instead redirecting both (stdout & stderr). This way only commands with failure exit status will be delivered.

    * * * * /path/to/ > /dev/null


  • Petr Topiarz alias kolaloka Mar 12, 2010 @ 14:43

    Thank you Edward,
    your “> /dev/null” was the only option that did the job for me. I run and adminster 3 servers with OpenBSD 4.3-5 and the cron did not like any other stuff but what you wrote. Thanks a lot. You saved me a lot of work.

  • Anoni Mouse May 9, 2010 @ 13:35

    It is not required to restart cron to effect changes to your crontab. Each time cron wakes up, it checks to see if the crontab has changed, and if so cron reparses it.

  • Bud Jun 13, 2010 @ 22:57

    Thank you OP and Anand Sharma

  • Frank Jun 26, 2010 @ 8:22

    I would like to know where I can adjust the email address of cron’s mail? Apparently I set an email address somewhere when I installed the server, but I’m unable to find where I can adjust that email address. I’m running debian lenny. Can someone help me here?

    • Fredrik Aug 3, 2010 @ 10:24


      Sure, use the MAILTO=”” trick, just don’t put “”


  • Chris Jan 5, 2011 @ 17:52

    Hi Vivek, great tip, thank you!

    The correct way to restart crond in HP-UX is:

    # /sbin/init.d/cron stop
    # /sbin/init.d/cron start

    Best regards.

  • Ilker Mar 12, 2011 @ 6:46

    I wrote to the top of my crontab file

    and the outputs of commands are not coming to my gmail adress. Why?

    Thank you.

  • Rosario Apr 15, 2011 @ 18:11

    @IIker, Have a look at your


    and reload with

    /etc/postfix/postmap sender_canonical

    /etc/postalias aliases

    with aliases you can send mails to root and other addresses without putting it in the MAILTO in crontab. That’s how I was told to do it and it works on my servers.

  • kthx Aug 3, 2011 @ 4:02

    MAILTO=”” is the best solution :P

    Thanks for the tip ;)

  • Howard Jan 31, 2012 @ 14:39

    Will this work for the at command as well?
    I’m trying to setup a series of commands that check for a condition and then reschedule themselves until it’s not true. The problem is every run sends an email to root, I need to stop that.

  • Mike Feb 7, 2012 @ 0:43

    Thanks for the tip, works great to disable cron emails.

  • Mickael Aug 24, 2012 @ 3:00

    Hi Vivek Gite,

    Thank you for your post.

    You can use several times the MAILTO variable in order to enable/disable e-mail sending to specific CRON job.

    # Disable e-mail sending
    * * * * * /bin/echo "Test email with MAILTO=\"\""
    # Send e-mail to
    * * * * * /bin/echo "Test email with MAILTO=\"\""
    # Send e-mail to
    * * * * * /bin/echo "Test email with MAILTO=\"\""
    However, multi e-mail in MAILTO generate for me the "(CRON) error (bad mailto)" (in /var/log/syslog)
    (Linux u-server-3-guest-2 2.6.38-10-virtual #46-Ubuntu SMP Tue Jun 28 17:54:41 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
    # The following does not work, but should, if somebody know why
    * * * * * /bin/echo "Test email with MAILTO=\",\""


  • Varun Verma Jan 9, 2013 @ 22:37

    Works like a charm. Thanks for sharing.

  • Rick Mar 20, 2013 @ 21:48


    I have another question for you. I want to set a cronjob which should be doing following:
    checking a error file if generated every night in a specific directory and if there is one then sending to 5 users email id?

    I think this should be done by creating a shell script and scheduling it every night.

    Thanks a lot

    • Mickael Mar 21, 2013 @ 4:09

      Hi Rick,

      I must say, it is not really a question about CRON, you are asking for writing a bash script?
      Could you give your current scipt and if you have an issue with CRON notification, you could details your problem.


  • Rick Mar 21, 2013 @ 14:55


    Thanks for replying here it is

    count=$(ls -1 ${err_log_dir}/*.err 2>/dev/null | wc -l)
    if [ $count != 0 ]
    	echo "ERROR: There was an error in loading data" >> ${logfile}
    	MAILTO="" >> ${logfile}
    	echo "No Error file was created." >> ${logfile}
  • Rick Mar 25, 2013 @ 16:22


    Any one can reply to my above query?


  • anonymous Oct 3, 2013 @ 20:26

    Try ‘if [ ${count} -ne 0 ] ; then ….

  • fireskyer Oct 21, 2013 @ 12:21

    How can i surpress certain
    Output from crontab ?

    for example:
    stdin: is not a tty line

  • ismail sebbane Feb 21, 2014 @ 15:04

    This solution suits me ^^
    I use MailTo = “myemail” at the beginning of the crontab-e line to receive all email on my mailbox
    For cron which I do not wish to receive mails I add> / dev / null 2> & 1 at the end of the cron

    Thank you.

  • Tim Jun 5, 2014 @ 22:15

    I tried this, but I receive an error:

    crontab: error on previous line; unexpected character found in line.

  • ankit jain Aug 19, 2014 @ 13:03


    Can u please tell me if i use MAILTO=”” option to stop receiving mails from cron then
    where this mails will be stored.?
    Will it go in trash or in queue ?

    • Corey Edwards Dec 2, 2015 @ 17:03

      To the best of my knowledge, cron will not even generate mail because it has no user or address to send the mail to, so it merely executed the jobs in place and the output vanishes into the great /dev/null in the sky.

  • arjun Dec 23, 2014 @ 10:04

    MAILTO not working on my server any other solutions

  • Alan Santos Oct 29, 2015 @ 20:02

    Work’s like a charm.


  • Corey Edwards Dec 2, 2015 @ 17:02

    It is also worth noting that you can mix this up as well. For instance, if you have ten cron jobs and you want email for eight of them, you can do as follows:

    cron job 1
    cron job 2

    cron job 8

    cron job 9
    cron job 10

    Cron, at least as of OS X El Capitan, which runs the latest BSD release, will use the default method of mailing the crontab owner for the first 8 jobs, then ditch any mail for the last two. You can mix it up further and specify different email addresses or user accounts for each cron job in your tab. Just note that when you use MAILTO=”foo”, cron will use that user or email address for every cron job that follows in the tab unless you redeclare MAILTO.

  • Regaug Jan 19, 2016 @ 20:49

    On some crond’s, one can handle this issue at a high level (and circumvent bad crontab files), by adding to /etc/sysconfig/crond: CRONDARGS=”-moff”, and then restart the crond daemon. This tells crond not to send mail at all.

  • Terrence Brannon Nov 6, 2016 @ 12:06

    Remove the period on your first unix command. E.g. instead of

    >/dev/null 2>&1.

    make it just

    >/dev/null 2>&1

  • Shyam Singh Chandel Aug 28, 2020 @ 17:05

    great it worked!
    >/dev/null 2>&1

  • Gldrk78 Feb 18, 2021 @ 23:18

    Thanks a lot for your guide to disable those mail notifications.

  • Esther Merope Mar 25, 2021 @ 13:00

    I wanted to stop cron daemon emails. This page wasn’t first on Google but worked like a charm. This is the best blog for solving Linux developers issues.

  • Melody Macy May 6, 2021 @ 4:57

    Thank you. Here is what worked for me:

    */5 * * * *  root /usr/local/sbin/my-service-pickup-job > /dev/null 2>&1

    But the following failed:

    */5 * * * *  root /usr/local/sbin/my-service-pickup-job 2>&1

    Depending on your system or shell you need to try out both version.

  • Doris Wochele May 6, 2021 @ 11:37

    Hi, I need also in
    this entry

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum