COVID-19: Hubken is working as normal Get in touch today

A common problem we see when performing health checks 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.:

Mozilla Firefox browser window with Moodle Cron information and settings

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:

Linux command in Crontab entry for Moodle Cron information and settings

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:

Windows Command Prompt for Moodle Cron output

(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 Hubken Group) 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 https://docs.moodle.org/28/en/Cron.

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.

 

Worried your LMS isn't up to scratch?

Get an LMS Health Check from us here at Hubken Group.

We'll give you a detailed, independent review of your self-hosted Moodle or Totara Learn site, checking through the configuration and environment of your LMS, and picking up any common problems that your LMS might have.

So if you think your LMS might need a tune-up, just give us a shout and we'll show you what we can do.

TALK TO US ABOUT HEALTHCHECKS

 

About Hubken:

The Hubken Solution  comprises powerful, flexible and tailored Learning Management System (LMS) services for organisations of all sizes. Leveraging the power of Moodle or Totara  platforms we provide you with the tools to achieve outstanding eLearning outcomes, supporting you in areas including LMS hosting, installation, user training, content development, reporting  and more.

‹‹ Previous Next ››

Related posts

What is an LXP? A quick guide for L&D professionals

If you’re responsible for managing e-learning programmes you’ll know what a Learning Management System (LMS) is. If you’ve attended any learning fairs in recent years you may have seen the term LXP popping up.

It stands for Learning Experience Platform and represents a whole new range of possibilities to expand the way your audiences learn.

OK, so here are the things made possible with an LXP:

Open Badges: A simple way to improve learner engagement

For anyone managing e-learning programmes learner engagement is surely a key measure of success. You may have hundreds of people in different departments or teams but all of them are likely to appreciate recognition for their efforts. That’s where Open Badges come in.

Open Badges enable your learners to get verifiable proof for the knowledge, skills and achievements they have developed through your e-learning programme.

Engage your learners with gamification in Moodle

The term gamification has been around for years, but what is it? Simply, it’s about bringing elements from game design into a non-game context and there are good reasons to do so.

Many people who’ve been in the workforce for years will have got into gaming as children but even for the non-gamers amongst us introducing gamification into your Moodle LMS can make a big difference (and implementing it can be much easier than you think!).