HowToMoodle Blog

How to keep your Moodle site up to date by checking your Moodle cron

by Joanna Barnfield on | Apr 07, 2015 | Blog | 0 comments

Moodle Cron clock HowToMoodle.gif

A common problem we see when performing healthchecks of our customers' Moodle sites is the "cron" process not working. It's configured correctly, and starts to run but doesn't get to the end. There can be a variety of causes for this, such as database issues or problems with third-party plugins. This post shows you how a system administrator can check if this is running correctly.

First some background:

What is Moodle cron

The "cron" process is an essential part of a Moodle site. If it's not being run, or not running correctly, then the site tasks that depend on this (e.g. course completion or emailing forum posts) are not occurring and temporary data may not be getting cleaned up resulting in a site being larger than it needs to be and not performing optimally.

The cron is usually set up when a site is installed and it shouldn't require any further intervention. But changes in the platform such as PHP and MySQL versions, and changes to Moodle and plugin versions can sometimes introduce unexpected problems. Unfortunately, any cron failure is silent: no error message occurs.

How to check if your Moodle cron runs correctly

There are two ways to check that cron is running correctly:

1. Run it from your browser.

2. Run it from the command line.

To run cron from the browser, enter your site's web address followed by "/admin/cron.php", e.g.:


For this to work, the option "Cron execution via command line only" under "Site administration" - "Security" - "Site policies" must be unticked and if "Cron password for remote access" is set, this must be supplied, e.g. "/admin/cron.php?password=your_password".

Using the command line is the best way to test cron as you can use the exact command being used for the scheduled task.

If you're using Linux, copy the command from the crontab entry. If this is redirecting the output, e.g. with "> /dev/null 2>&1", do not include this as this removes the output we want to check. A sample command and output is shown below:


On Microsoft Windows open a "Command Prompt" window (normally this must be run as an Administrator). Then copy the command and parameters from the scheduled task in the "Task Scheduler" console. Make sure you run "php.exe" here instead of "php-win.exe" as the latter suppresses output. You may need to put the command in quotes if it contains spaces, e.g.:

"C:\Program Files (x86)\PHP\php.exe" -f D:\Apache22\moodle\admin\cli\cron.php.

A sample command and output is shown below:


(There are other ways to run the cron, e.g. using moodlecron.exe or curl, these are not covered here).

In all of the above cases, both using the browser, or the command line, the final lines of the output should be something like:

Cron script completed correctly
Cron completed at 13:18:11. Memory used 11.3MB.
Execution took 8.21016 seconds

If you're seeing error messages, then the next step is to investigate. Maybe it's a problem with a plugin which can be disabled or updated. Maybe you can fix it yourself, perhaps with the help of the Moodle forums. If you're still struggling, maybe a Moodle Partner (like HowToMoodle) can help!

One final note. Your site may not have the cron set up at all. In this case you will see this message on the "Site administration" - "Notifications" page:

The cron.php maintenance script has not been run for at least 24 hours.

If this is the case, you should get this configured as soon as possible. Comprehensive instructions are available from

If you are setting this up for the first time you may wish to add the following line to "config.php" (or just above the "?>" if it's present) for the first run:

$CFG->noemailever = true;

This will prevent any email being generated which, for an existing site that has had no cron running could prevent a lot of out-of-date and unwanted email. Don't forget to remove the line after you have got cron working.

What Next

You can find more information about our Healthcheck service at

If you need help with your Moodle site, we want to hear from you. Contact us on 0330 660 111 or via our website at

Happy Moodling! 

Expert Technical Support for your Moodle or Totara Learn site

Share this: