Home Download Ubuntu

How to disable/enable email alerts by crontab command from Ubuntu

Each time a job is succesfully executed by crontab, it sends an email. You might receive e-mails from root account from cron.

To disable crontabs email alerts:

Edit crontab:

sudo crontab -e


And at the end of each cronjob you need to append >/dev/null 2>&1 like this:

0 1 * * * /path/to/script.sh >/dev/null 2>&1


To enable crontab email alerts and setup email for it:

Edit crontab:

sudo crontab -e


At the begining of the file insert MAILTO=admin (admin will be the email where the alerts will be sent). You will need to have a mail server configured or to configure an external email server to be used. Example:

MAILTO=email@domain.com

0 1 * * * /path/to/script.sh


Resources: cyberciti.biz

0 comments:

Post a Comment