Why is my cron job not emailing me?

Many of our account holders use cron jobs to perform tasks at specific times. These jobs run at schedulee intervals set within the cron job tool in the cPanel. One of the features of this tool allows you to set an email address so that you receive an email every time the cron job runs. This allows you to keep track of your cron jobs and ensure they are running correctly and as scheduled. However, sometimes we receive support questions that some cron jobs are running but the email is not being received. Follow below as we explain how to ensure you get an email for every cron job.

Force an email after cron job is run

  1. Log into your cPanel.
  2. From within the main cPanel area, scroll down and find the Advanced category. Click on the cronjobs icon found in that category.
  3. Now you are in the cron job setup screen. At the top is a Cron Email area where you can enter the email address you want to receive notice every time a cron job runs. Double-click on the word more at the end of the description to open the field to add your email address. Enter your email address here if you do not see an email address next to Current email:
    cron notification email setting

  4. If you already have an email address in that section and are not receiving an email for one or more of your cron jobs, this is because that the job in question is not producing output. We want to force some sort of output, so from the cron job screen, look at the path of the cron job in question so you know where the script lives. Write down the path if necessary.
    path to cron job
  5. Now that we know where the script is, go back to the main cPanel page and open up the File Manager from within the Files category.
  6. Once in the File Manager, navigate to your cron script. In our sample, it is simply under the public_html/test folder and is named testcron.php> Locate your file and highlight it, then click on the Edit icon found in the upper toolbar of the screen. Another popup will appear, simply click on the Edit button there as well to continue to the editor.
    edit cdon script dile
  7. Now that you are in the editor, we want to add a single line to ensure some output is produced. This can be anything from as simple as a space to a sentence. Below is the code we will add to the end of our script:
    echo “done”;

    Be sure the line of code is before the php closing tag of ?>.

  8. Click on the Save Changes button at the top of the screen. Your cron job should now email you every time it runs with the single line of output.

0 thoughts on “Why is my cron job not emailing me?

Was this article helpful? Join the conversation!