Ubuntu – Stop cron from mailing the user


I am facing an issue with Ubuntu server. I am running a PHP script using a cron job which executes every 5 minutes. This folder spool/mqueue is showing 112GB space. The scripts job is to fetch data from MySQL. If there is no data it will show an error. Now there is an error and cron is trying the send the mail to the users where user email is not defined and it is creating log file in mqueue folder.

How to customize cron so that it would not send mails and write logs?

Best Answer

You can set the MAILTO variable in your crontab.

Just type the following at the top of your crontab (crontab -e):


and cron will not send any mail for any of the jobs. If you have to disable mails for a specific task, use the following:

@hourly /path/to/script.sh >/dev/null 2>&1
Related Question