How to remove the notification of the cron
This article has been created by an automatic translation software. You can view the article source here.
Introduction
By default, to the achievement of a task to the crontab, Cron sends an email notification to the user in question containing the complete output of the executed script.
For some use, this notification is important because it allows to know if the shares are passed correctly.
However, in other cases, it can be annoying, especially if the tasks are carried out over short periods and therefore sending emails in bursts.
The deletion of the notification for a particular task
To prevent a particular task to send an e-mail, just add a directive asking him to redirect the output to nothing at the end of the command (/dev/null), it is possible to achieve two ways :
- by adding > /dev/null 2>&1 at the end of the command,
- by adding &> /dev/null at the end of the command.
The result for these two cases is the same, you will not receive more mail notification regarding this task.
Here is a complete example :
59 23 * * * root /home/backup/backup.cmd &> /dev/null
Or :
59 23 * * * root /home/backup/backup.cmd > /dev/null 2>&1
Deleting complete notifications for a user
To completely remove the notifications by mail for a user, simply use the MAILTO variable in the crontab.
At the beginning of the crontab file (before the definition of the tasks ), so just add the line :
MAILTO=""
It is also possible to use this variable to send notifications on a different email than account, current user's local.
To do this it is sufficient to indicate a specific email :
MAILTO="utilisateur@domaine.tld"
This article seemed you to be useful ?
Enable comment auto-refresher