Cyber Week Deals! Save 80% on all Shared Hosting Plans & Locations - Starting from $1.99/mo

How to Disable the Mail Alert via Cron Job

Updated on Oct 26, 2022

The task scheduler Cron is in charge of ensuring that scripts run at the times they are supposed to. Cron is frequently used for tasks like log rotation, backup scripts, file index updates, and execution of user-written scripts.

If the cronjob cannot normally run when it is run, an email will be sent to the root user. A cron job or script that has successfully run will email the results to your local mail account. We'll briefly go through how to stop receiving mail alerts from Cron in this post.

This post includes:

Method 1: Stop Receiving Email Notifications from Cron by Adding Strings

You must include one of the following strings to the end of the cron job command if you want to cease receiving output for the run cronjob regardless of whether it is successful or not:

>/dev/null 2>&1

or

&> /dev/null

An Example

After the authentication in your cPanel account click on the Cron Jobs icon from the Advanced section.

Find the Cron Jobs menu in cPanel

On the following page, you need to click on “more »” to make the Email field available. Here you should put the email for cron job notifications. Once you are done, you can click on “less »” to hide this field.

Add Email Address 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:

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

or

php /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.

Method 2: Use the MAILTO variable to Stop Receiving Email Notifications from Cron

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=""

Additionally, this will prevent the email notifications of the cron job.

If you experience any difficulties while disabling the mail alert via cron job, feel free to open a ticket and contact our technical support experts for assistance.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

cPanel Hosting

  • Free Domain Transfer
  • 24/7 Technical Support
  • Fast SSD Storage
  • Hack-free Protection
  • Free Script Installation
  • Free Website Transfer
  • Free Cloudflare CDN
  • Immediate Activation
View More