How to disable the mail alert by cron job command.

When the cronjob is executed and the job cannot run normally it will send an email to the root user. The output of a successfully executed cron job or script will be sent via email to your local mail account. If you would like to stop receiving output for the executed cronjob no matter if the same is successfully executed or not you will need to add one of the following strings at the end of the cron job command:

>/dev/null 2>&1

or

&> /dev/null

For example after the authentication in your cPanel account click on the “Cron Jobs” icon from the “Advanced” section. On the following page, you will notice an “Email” field, here you should put the email for cron job notifications. After the email and all of the time execution fields at the bottom is the “Command” field where the same should be set with the following commands:

cd /home/user/public_html/cron.php  > /dev/null 2>&1

or

cd /home/user/public_html/cron.php  &> /dev/null

No matter which of the commands you choose and set, the email notifications upon execution of the cron job will be interrupted.

MAILTO variable

Another way to prevent email notifications is to edit your cron job file. After the cron job file is opened and ready for editing you should add the following line at the top of the cron job file:

MAILTO=""

This also will prevent the email notifications of the cron job.

  • 0 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Powered by WHMCompleteSolution