Skip to content

Moodle cron not running? How to check it and fix it

Fix a Moodle cron job that isn’t running: read the status warning, set up the schedule, check the PHP version and confirm that tasks run again.

Muhammad AhmadMuhammad AhmadFounder & Software Engineer8 min read
Laptop on a desk showing Moodle’s warning that cron has not run
Short answer

If Moodle cron isn’t running, background work waits: many emails, course completion updates and some backups. Open Site administration › Reports › System status and read the Cron running check. Then schedule admin/cli/cron.php to run every minute, as the web server’s user, with a PHP version your Moodle supports.

We tested these checks on a new Moodle 5.3.1+ site on December 1, 2026. The status messages, command output and screenshots come from that test. We ran cron by hand there, so the scheduling steps for Linux, hosting panels and Windows follow Moodle’s documentation.

How to check if Moodle cron is running

  • System status: go to Site administration › Reports › System status and find Cron running.
  • Notifications: the Site administration notifications page shows a warning when cron has not run.
  • Scheduled tasks: under Site administration › Server › Tasks › Scheduled tasks, the Last run column shows when each task last ran.
Moodle System status showing a warning that admin/cli/cron.php has not been run for 4 minutes 58 seconds and should run every 1 minute
The Cron running check on our Moodle 5.3 test site, a few minutes after our last manual run.
What the cron messages in Moodle 5.3 mean
MessageWhat it meansWhat to do
“has never been run”No run has been recorded on this siteSet up the scheduled job
“has not been run for” a length of timeThe job has stopped, or runs too rarelyCheck the job exists, then run cron by hand and read the output
“between the last two runs of the cron maintenance script”Cron ran, but the last gap was too longFix the schedule so runs stay close together
“Cron is running frequently”Recent runs are on timeCheck for failing tasks as well

How to set up the Moodle cron job on Linux

Add the job to the crontab of the web server’s user. On Debian and Ubuntu that user is usually www-data; Moodle’s documentation gives apache for CentOS. Open that user’s crontab:

Open the crontab
sudo crontab -u www-data -e

Add this line, with your own PHP path and Moodle folder. The five stars mean every minute, which is what Moodle recommends.

crontab
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null

The >/dev/null at the end throws away the normal output, so you don’t get an email every minute. It also hides what you need while troubleshooting. Until cron works, send the output to the system log instead:

crontab, with logging
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php 2>&1 | /usr/bin/logger -t moodlecron

cPanel and shared hosting

Hosting control panels usually have a Cron Jobs section. Set the job to run every minute and use the same kind of command. The PHP path often differs between hosts and PHP versions, so ask your host for the command-line PHP path that matches your Moodle. If the plan does not allow a job every minute, ask the host what it does allow.

Moodle cron on Windows

Use Windows Task Scheduler to run Moodle’s script with PHP. This is the command in Moodle’s Windows guide, with example folders:

Task Scheduler command
c:\php\php-win.exe -f c:\moodle\admin\cli\cron.php

The Windows guide shows a repeat every 3 minutes, while Moodle’s main cron page recommends every minute. Choose one minute, and use Run on the task to test it.

The path on Moodle 5.1 and later

Moodle 5.1 moved web files into a public folder. In the Moodle 5.3.1+ package we tested, the command-line script we ran is still admin/cli/cron.php in the main Moodle folder, not inside public. If you changed paths during an upgrade, check the cron line against the files on your server. Our Moodle 5 upgrade guide explains the folder change.

Run Moodle cron manually and read the output

Running cron yourself shows whether the problem is the script or the schedule. Run it as the web server’s user, from any folder:

Run cron once
sudo -u www-data /usr/bin/php /path/to/moodle/admin/cli/cron.php

Each task prints when it starts and finishes. A run that reaches the end looks like this (shortened, from our test site):

Output
Server Time: Tue, 01 Dec 2026 17:22:37 +0000

Execute scheduled task: Cleanup old sessions (core\task\session_cleanup_task)
... started 17:22:37. Current memory use 12.8 MB.
... used 7 dbqueries
... used 0.015257120132446 seconds
... used 15.4 MB peak memory
Scheduled task complete: Cleanup old sessions (core\task\session_cleanup_task)
...
Cron run completed correctly
Cron completed at 17:23:05 in 27.492898 seconds. Memory used: 50.6 MB.
Studio tipDon’t stop at the last line. In our first run, a login notification email failed because the test server had no mail program, yet the run still ended with “Cron run completed correctly”. Search the whole output for “error” and “failed”.

If cron works but messages still don’t arrive, follow our guide to Moodle emails not sending.

Errors when you run Moodle cron by hand

Messages we reproduced on Moodle 5.3
MessageCauseFix
“Could not open input file”PHP can’t find the script at that pathCorrect the path. On our test site, public/admin/cli/cron.php did not exist
“Cron is disabled. Use --force to override.”Cron is switched off for the whole siteFind out why, then enable it with the command below
Enable cron again
sudo -u www-data /usr/bin/php admin/cli/cron.php --enable

Don’t expect a clear error if cron runs as the wrong user. On our test site, a run as another user still started its tasks. Wrong ownership can cause permission problems later, so keep to the web server’s user. To see which tasks are running now, add --list to the cron command.

Why the cron warning stays after you run it once

On our test site, one run after a gap of about 13 minutes did not clear the warning. Moodle changed the message to “There was 12 mins 53 secs between the last two runs of the cron maintenance script and it should run every 1 min.” After we ran cron again shortly afterwards, the check showed OK.

So a manual run proves the script works, but it doesn’t fix the schedule. With a job running every minute, the gap stays short on its own.

Moodle System status showing OK for Cron running with the summary Cron is running frequently
The same check on our test site after two runs close together.

Check which PHP version cron uses

Moodle’s documentation warns that the command-line PHP program is separate from the one running your website, and may be a different version. After a PHP or Moodle upgrade, check both. Moodle 5.3 requires PHP 8.3 or later.

Command line PHP
which php
php -v

If the version is too old, find the right PHP program and use its full path in your cron line. The path depends on your server.

Don’t rely on cron to tell you. We ran the same Moodle 5.3 test site with PHP 8.2.36. cron.php showed no version warning and reported that the run completed correctly. When we ran install_database.php with that PHP version, it stopped with this message:

From install_database.php, not cron.php
Moodle 5.3 or later requires at least PHP 8.3.0 (currently using version 8.2.36).
Some servers may have multiple PHP versions installed, are you using the correct executable?

This was one test on a new site. It does not make PHP 8.2 safe for Moodle 5.3. To see what your version needs, use our free Moodle upgrade path planner.

One Moodle task keeps failing

Cron can run on time while a single task fails. According to Moodle’s documentation, a failing task doesn’t stop the others. Moodle tries it again later and waits longer after repeated failures, up to once every 24 hours. Check Tasks max fail delay on the System status page, then open the task’s entry in Logs on the Scheduled tasks page. That column does not show ad hoc task failures.

To watch one task run, list the scheduled tasks and then run the one you need. Run these from the main Moodle folder, and keep the single quotes around the task name:

One scheduled task
sudo -u www-data /usr/bin/php admin/cli/scheduled_task.php --list
sudo -u www-data /usr/bin/php admin/cli/scheduled_task.php --execute='\core\task\session_cleanup_task'
Studio tipRunning a task by hand really runs it, even if it is disabled. Some tasks send messages or change data, so read what a task does before you run it on a live site.

How to confirm Moodle cron is fixed

  • Cron running shows OK on the System status page, and still does 15 minutes later.
  • The Last run times on the Scheduled tasks page keep moving without anyone running cron by hand.
  • Tasks max fail delay reports no failing tasks.
  • The command line PHP version is one your Moodle release supports.
  • A real notification, such as a forum post email, arrives.
  • While troubleshooting you logged the output: check it for errors before you hide it again.

Moodle cron questions

How often should Moodle cron run?

Every minute. Moodle’s documentation recommends it. Each task has its own schedule, so running cron every minute doesn’t run every task every minute.

Why are Moodle emails and course completion delayed?

Many Moodle emails are sent by background tasks, and course completion is calculated by scheduled tasks too. If cron stops or runs rarely, that work waits. Check cron first, then the mail settings or completion settings.

Can I run Moodle cron from a web address?

Moodle calls web cron deprecated and recommends command line cron where possible. Access from the web is switched off by default. If you must enable it, set a cron password for remote access.

Where is cron.php in Moodle?

Use admin/cli/cron.php for command line cron. In the Moodle 5.3.1+ package we tested, it is under the main Moodle folder, not the public folder. There is also a web version of cron, which Moodle has deprecated.

If cron still stops, or tasks keep failing, our Moodle support and maintenance team can trace the problem through the server, PHP, scheduled tasks and email.

Related serviceMoodle SupportUpdates, backups, monitoring and developer hours.
Muhammad AhmadWritten byMuhammad AhmadFounder & Software Engineer at StackStead Solutions. Building for the web since 2020.Ask a question