How to Check if a Cron Job has Run (Crontab Log)

A fairly common question for scheduled tasks that run in the background is, “Are they running?” These tasks, commonly known as cron jobs, are tasks that need to automatically run for maintenance, backups, and other functional needs for the website and server.

In order to determine if your cron jobs are running, you will need to distinguish between the scheduling of the tasks (the crontab) and the actual tasks themselves (the cron jobs). Cron jobs that do not produce output results require that you become familiar with the server logs. Upon determining the results of the server logs, you can then troubleshoot cron jobs that are not running. You can also modify a script so that it produces an output to show that it is running.

The following article will help you distinguish between a crontab and a cron job, two ways you can see when a cron job is running, and how to troubleshoot cron jobs that are not running.

NOTE: To perform this function, you will need to have root access on your VPS or Dedicated server.

Difference Between Crontab and Cron Job

To help prevent confusion between a beginner administrator and a developer or experienced server administrator, it is important to understand the meaning of the terms “crontab” and “cron job.”

If you search for “scheduling cron jobs”, you will find the term crontab defined or described with hardly any introduction. The term crontab is short for “cron table’ and is a Linux command for scheduling cron jobs. The crontab is also the actual text file that contains the scheduling for cron jobs.

A cron job is an actual code or script that you are trying to run in the background at a particular scheduled time. The Linux command for a cron job is simply cron.

So, if someone asks you how a cron job is scheduled in the crontab, you know that they are referring to the timing and frequency information applied to the cron job in the text file known as the crontab.

For the purposes of cPanel, the crontab and cron job can be edited directly in the cPanel interface on the Cron Jobs page.  Here you can see the upper portion of the Cron Jobs page:

Cron Jobs page - upper half

If you have any existing cron jobs, then you will see them at the bottom of the Cron Jobs page.  You will see the timing for the cron job (from the crontab file) as well as the code for the cron job.  You can add, edit, and delete cron jobs and their corresponding schedules on this page. Here’s how the bottom section looks:

Cron Jobs page - lower half

Using the crontab information provided in cPanel you can determine when a cron job was supposed to run. In some cases, cron jobs will not generate an output, so it is important that you become familiar with the generated log files and how to search them.

2 Ways to See If Your Cron Job is Running

Checking the Log Files

In this example, we will search the crontab log by using the fictional file name The command commonly used to search for files or characters in a particular pattern is grep. This terminal command can be used to search the log file for instances when “” is running. This is the command used to search for “” in the cron log file:

grep “” /var/log/cron

If you were to search for a different script or term in the log file, then you would simply replace “” with the name of your script file or text string that you’re trying to find in the log.

Using the grep command, you can view the log to see the last time when the specific script in the cron job was executed.  If the cron job does not produce a visible output, then you would need to check to see if the cron job has actually taken place. 

For example, you can see the last time when a cache clearing cron job was executed. You would then check to see if the cache is cleared by seeing if the cache is empty or not.  Here’s an example of seeing a cronjob running by checking the log:

The log shows a record of when the file was run.  Please see our tutorial if you need information on how to access the terminal through cPanel.

Using Output In a Script to Show a Running Cron Job

The easiest way to see if a cron job (with its crontab settings) is working is to edit an existing cron job so that it produces a visible output. You can add a line of code in your existing script to output a result when the script is run. If the result of this command produces an output, then you can use this output to confirm that your cron script is running.

The modification of a cron job script should not be performed by a user who is not familiar with the code or script being executed. Since cron jobs can be written in many different ways, you may need to speak with an experienced developer to help prevent any issues with your website.

Troubleshooting Cron Jobs

If you are not seeing any activity in the crontab log or if you are not receiving an email regarding the cron activity (for cron jobs with an output), then you will want to first double-check that the time parameters for the cron job are correct. This will help to determine if (and when) the cron is supposed to be running so that you can properly troubleshoot possible issues.

If you are still suspecting a problem with the cron job, then there are normally 3 possibilities why it might not be running:

  1. The cron daemon (the system process that runs cron jobs) could not run the script or was unable to send an email
  2. There were issues with the mail server mailing the output or the email was lost
  3. The cron job did not produce an output or error message

In all three cases, the cron job is silently failing. In other words, there is no visual result of the cron job running.

In the first possibility, you will need to check the system log on the webserver in order to search for errors that may be recorded during the attempted execution of the cron job. You can then use the error message to isolate where the cron job script may be failing and make necessary corrections.

You may also need to go through the mail server log to double-check if there was an attempt to send an email after the completion of the cron job. Remember that the designated email address is set near the top of the cron job page in cPanel. You can use the email address to isolate the mail attempts in the mail server log.

You would also check the mail server log if you are seeing the record of the cron job running, but no expected email. Emails are sent on the successful completion of cron jobs with an output.

In the third possibility, you will need to add code to your cron job so that it produces an easily tracked output to verify that it is running.

If you are unsure how to check mail server logs, then contact your hosting service’s technical support or work with an experienced administrator to use the logs to help you identify problems related to the mail server.

There are many ways that a cron job can fail. If you are not sure how to code cron jobs then consult with an experienced developer to help you make corrections or modify code for troubleshooting purposes.

You can read our full guide on setting up cron jobs in cPanel if you need more information about that topic.

Make sure your business, agency, or reseller clients are always connected and powered on with our optimized Managed VPS Hosting.
Arnel Custodio Content Writer I

As a writer for InMotion Hosting, Arnel has always aimed to share helpful information and provide knowledge that will help solve problems and aid in achieving goals. He's also been active with WordPress local community groups and events since 2004.

More Articles by Arnel

20 thoughts on “How to Check if a Cron Job has Run (Crontab Log)

  1. Actually i have create one script for dev env. my query was i am given some x value. but script was executed in before timing.
    Anyone why its is running before time.

    1. Hello! Just to check, did you confirm that your Development Environment’s time is using the time zone you expect? If you did not configure that yourself, it may be set up to use something automatically that is incorrect. Beyond that, I’d suggest running your CRON script through a tool like crontab and double checking that it works as you want it to. Hope that helps!

    1. I recommend you check the logs as indicated in this guide to determine why the cronjob is not running as expected.

      I also recommend you check what user you are using for SSH and what user is running the cronjobs to figure out why crontab is not displaying anything.

      I do apologize, however, I am not able to determine why your cronjob is not working, with the details you have provided.

  2. Just a quick tip if you’re looking for a cron job that ran in the past run
    grep “cronscript.php” /var/log/cron-20171008 (which says cron file that is logged at 2017-10-08)

    1. Hello Simon,

      You should not have to, is the code above not working for you?

      Best Regards,
      TJ Edens

  3. i want to find how many jobs are running and on which server  these things i want but didnt get using these commond plz help me. 


    1. Hello Sreenu,

      You can see any crons running on the server by checking /var/spool/cron for the given user. And you will see the active crons running in the chosen user’s “crontab”.

    1. Hello Kenny,

      If you have a mailto line setup within your crontab then you should get emails from any failing cron jobs.

      Best Regards,
      TJ Edens

Was this article helpful? Join the conversation!