Cron job e-mails flooding your inbox: MAILTO and where the output should go

The short answer: whenever a scheduled task (cron job) writes anything to the screen, the system e-mails that text to the cron address. A task that runs every five minutes can send hundreds of messages a day. The fix is to tell the task where the output goes: to a file, or nowhere.

Where the output goes

End of the command What happens
>/dev/null 2>&1 Throws everything away, errors included. Total silence. Careful: it hides failures.
>/dev/null Throws away the normal output, but errors are still e-mailed. Usually the best.
>> /home/account/cron.log 2>&1 Keeps everything in a file, to read when you need. Remember to clear it now and then.
Nothing Everything the task writes goes by e-mail.
Changing the address In cPanel, the “Cron Email” field is at the top of the cron jobs page. On a VPS, it is the MAILTO= line at the start of the crontab.

Step by step

1 Open scheduled tasks (Cron Jobs, in cPanel) and see the “Cron Email” field at the top. Choose an address you read, or leave it empty.
2 Decide what you want to know: only errors, or nothing, or everything in a file.
3 Edit the task’s command and add the right ending, for example: /usr/bin/php /home/account/script.php >/dev/null. Running a PHP script from a cron job.
4 On a VPS, put MAILTO="" at the start of the crontab to switch e-mail off for all of them, or the address you want.
5 Clear the mailbox and confirm, days later, that the messages stopped: Mailbox full.
Do not hide everything from a task you never tested. If the output goes nowhere and the task fails, nobody knows. First confirm it works, then silence it: A cron job that does not run.
For the schedule syntax: Schedule examples. A task every five minutes is not always needed: Cron jobs worth setting up. On WordPress: WP-Cron for a real cron job.

Getting hundreds of cron messages and do not know which task? Open a ticket with the subject of one of them.

Open a support ticket

SEE ALSO

Cron jobs: what they are for and how to create one

A cron job that does not run or sends no output: a checklist

Cron schedule examples: every 15 minutes, weekdays at 8, the first of the month

Running a PHP script from a cron job

Swapping WP-Cron for a real server cron job

Your mailbox is full: what to delete and how to stop it happening

RECOMMENDED PRODUCT

Professional e-mail on your domain

Mailboxes in your company name, no adverts, with spam filtering. from 5.940,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?