Why Moodle cron setup decides whether scheduled work runs at all
A new or migrated Moodle site often looks healthy in the browser while its background work never runs. Moodle needs its CLI cron script run every minute by the operating system, and nothing in the web interface does this job for you. If that schedule is missing, the work that depends on it stops silently: message and notification delivery, scheduled course backups, log and cache cleanup, cohort and enrolment syncs, and the queue of ad hoc tasks that handles course copies and restores. Users see no error page. Administrators find out weeks later when a backup report is empty or a teacher asks why an email never arrived.
Moodle runs its work through a task model. Scheduled tasks are defined by the core code and by each plugin, and each has its own interval. Ad hoc tasks are queued by user actions and picked up on the next cron pass. The cron script checks which tasks are due and runs them, so its own frequency sets the ceiling on how promptly anything runs. This is why the every-minute expectation matters even for tasks that appear to run daily. A quick check is to confirm that the last cron run time in the site's task and status reporting is recent, and to compare it with the time on the server, because a stale timestamp is the first sign of an unscheduled or failing job.
Before you go live, confirm three things with your own environment rather than assuming defaults: which system account runs the cron job, that the web server user can write to the moodledata directory the task uses, and that web cron is not left enabled as a substitute. Moodle may show a warning if cron has not run at the expected frequency, so the status checks are the place to verify the schedule once it is in place. Teams that migrate sites should also check the schedule on the destination server, since a copied database carries over task records but not the operating system cron entry that drives them.
Choosing a cron scheduler for your Moodle server
This table compares system crontab, systemd timers and a container orchestrator CronJob for running Moodle's CLI cron every minute. Read each row against your server layout, since the same scheduler can behave differently across distributions, container platforms and monitoring setups, so confirm the behavior in your own environment before you rely on it.
| Option | When it fits | How failures show up | How it runs as the web server user | What it adds to operations |
|---|---|---|---|---|
| System crontab | A single Moodle server or a small cluster where administrators already manage cron entries on the host | Output goes to mail or a log file only if the entry redirects it; a silent failure can go unnoticed until the cron frequency warning appears | Runs as the user whose crontab holds the entry, so the entry is placed in the web server user's crontab | Minimal new tooling; checks depend on your own log review and alerting |
| systemd timer | A Linux host using systemd where you want logging to the journal and explicit unit dependencies | Failed runs are recorded in the journal and the unit state can be queried, but you still need an alert to act on them | Set with User= in the service unit, so the PHP process runs as the web server account without a login shell | Structured logs, catch-up options and dependency ordering; the unit files become configuration to version and review |
| Container orchestrator CronJob | Moodle runs in Kubernetes or a similar platform and the cron run should follow the same image and config as the web pods | Failed and missed job runs are visible through the orchestrator's job history, subject to its retention settings | Set through the pod security context, so the run user, file permissions on moodledata and config access must match the web pods | Shared deployment pipeline, resource limits and history; adds cluster configuration to operate and secure |
| External job scheduler | Your organization already runs a central scheduler that tracks jobs across many systems | Failures appear in the central console and can route to existing incident processes, provided the Moodle job is registered and monitored | Depends on the agent or remote execution method; confirm it can run as the web server user and reach the Moodle directory | Central audit, dependency handling and ownership records; adds a dependency on that scheduler's availability |
| Web cron (for comparison only) | Not recommended for production; it depends on visitor traffic to trigger tasks | Gaps appear when no one visits the site, and failures are hard to see | Runs inside the web server request context, so it does not use a separate system user | Avoid for production; keep it disabled so it does not compete with CLI cron |
How to set up Moodle CLI cron every minute
This sequence replaces browser-triggered cron with a system scheduler that runs Moodle's command-line cron once a minute under the correct PHP user. It produces a site where scheduled tasks, notifications and queued jobs run on time without depending on visitor traffic.
Confirm the PHP CLI version and path
The administrator logs in to the server over SSH and checks which PHP binary the web server uses, then confirms the CLI binary resolves to the same version and extensions. Run
php -vandphp -mfor the command line, and compare them with the PHP version shown in the Moodle environment check on the site. Record the full path, such as the output ofwhich php, because the scheduler entry must call that exact binary. Paths and versions differ by distribution and by how PHP was installed, so confirm them on your own server. The step is done when both versions match and the required extensions are present on the CLI.Identify the web server user
The administrator finds the account that runs PHP for the web server, which is commonly the user configured in Apache or Nginx and PHP-FPM pools. Check the process list or the PHP-FPM pool configuration to confirm the user name. This user owns or must be able to read and write the moodledata directory and the code directory, so cron files and caches are created with the right ownership. The user name is environment-specific and should be confirmed on your own server rather than copied from a guide. The step is done when you have the exact user name and can show that it is the account serving Moodle pages.
Run cron manually as the PHP user
The administrator runs the CLI cron script once as the web server user, using the confirmed PHP path. The command takes the form of the PHP binary followed by
admin/cli/cron.php, prefixed withsudo -uand the user name if the admin account is different. Watch the output for scheduled task names, errors and any permission warnings about moodledata. A clean run with no permission errors shows the script can read the code and write to the data directory under the right account. The step is done when the command completes without fatal errors and the output lists tasks being run.Add the one-minute schedule entry
The administrator adds a crontab entry for the web server user that runs the same command every minute, using
* * * * *as the schedule. Redirect standard output and errors to a log file that the administrator can read, and make sure the log path is writable by that user. Keep the entry in the crontab for the web server user rather than root, so tasks run with the same permissions as the web process. If your organization uses a different scheduler such as a systemd timer or a container job, apply the same user, path and logging rules there. The step is done when the entry is saved and the first scheduled run appears in the log within a minute.Turn off web cron in site settings
The administrator opens the site administration cron settings and confirms that the option for running cron from the web is disabled, so the browser no longer triggers cron on page requests. Keeping web cron on alongside the system schedule can cause overlapping runs and unpredictable timing. Check the site's cron settings page for any remaining warning about the cron frequency. The step is done when web cron is off and the settings page no longer shows the browser-triggered method as active.
Check the cron frequency warning
The administrator returns to the Moodle status or environment checks and looks for the cron frequency warning, which indicates that cron has not run as often as expected. After the first few minutes of scheduled runs, the warning should clear. If it persists, check the log file for errors, confirm the crontab entry is saved for the correct user, and verify that the PHP path still resolves. The step is done when the cron frequency check passes and the log shows a run each minute.
Verify runs in the scheduled task reports
The administrator opens the scheduled tasks report and the ad hoc task queue to confirm that tasks have a recent last run time and that no tasks are failing repeatedly. Check the cron log for failures tied to specific plugins. Confirm the last-run timestamp of the cron task itself advances every minute during a monitored window. Record the result and the log location in your operations notes so the next administrator can repeat the check. The step is done when recent runs appear in the reports and the failure list is empty or explained.
Running several cron processes on larger Moodle sites
A single web server running one cron entry usually needs no extra processes. Each run works through due scheduled tasks and queued ad hoc tasks, and the queue normally clears before the next run starts. Adding parallel processes at this size mostly adds database load and overlap risk without a clear gain.
- One cron entry is enough: keep the single
admin/cli/cron.phpentry from the minute-level setup and run it as the web server's PHP user so file permissions onmoodledatastay correct. - Check the queue before changing anything: if the ad hoc queue empties in each run, there is nothing to speed up.
- Keep web cron off: only the CLI entry should drive scheduled work, so browser visits do not start extra runs.
- Watch for runs that outlast the interval: a run that is still going when the next one starts is the first sign that a single process is no longer enough.
- Do not add processes for appearance: the question of how many processes to run only matters once the queue backs up.
Close by checking that the task logs show each run finishing well inside the interval and that no task waits across several runs.
When notifications, course copies or backups pile up, the queue grows faster than one process can clear it. Additional cron processes can take tasks from the same queue in parallel. Moodle uses locks so a task is not run twice, but the load on the database and file storage rises with every extra process, so the gain has a ceiling.
- Find the blocker first: a long-running or repeatedly failing task holds up the work behind it. Adding processes does not unblock a stuck plugin, so read the ad hoc task list and logs before scaling.
- Confirm overlap behaviour for your version: check the task documentation for your Moodle release to see which tasks are designed to run concurrently and which rely on exclusive locks.
- Track database load: watch connection counts, slow queries and user-facing response times while the extra processes run. Stop adding processes when response times for users start to degrade.
- Stagger the starts: launch extra processes at different offsets, each with its own log file, so they do not all compete for the same resources at once.
- Test the count on your own hardware: add one process at a time, measure how quickly the backlog drains and what the database experiences, then choose the lowest count that meets your target.
Close by confirming that the backlog shrinks in the task list over several runs and that pages used by learners stay within your acceptable response times.
In a cluster, scheduled work should run from a controlled host or a small set of hosts, not from every web node. Each web node running its own cron entry produces duplicate scheduled work, overlapping runs and contention for the same locks. Cluster design decides where cron lives, and that decision matters more than the process count.
- Designate the cron hosts: run cron from a dedicated node or a small defined set, and remove the cron entry from the other web nodes so only intended hosts start runs.
- Share configuration and data paths: every node that runs cron must read the same
config.phpand point at the samemoodledatalocation, or the task will act on a different site state. - Use a shared lock configuration: locks held on one machine do not stop another machine from starting overlapping work. Confirm the lock store used by your cluster is shared across nodes.
- Choose the scheduler deliberately: a system cron entry, a process supervisor or an orchestrator's scheduled job each handles restarts, logging and missed runs differently. Document which one you chose and how a missed run is detected.
- Plan failover: define what happens when the cron host fails, how the replacement is started and who receives the alert.
Close by checking monitoring to confirm that only the intended hosts run cron and that run start and end times do not overlap across the cluster.
Security and operational considerations for cron
Cron is the process that keeps Moodle's scheduled tasks, messages and housekeeping moving, and it runs with the access of the account that starts it. The cards below cover who runs it, what can reach it, where its output goes and how you find out it has stopped, so the setup you build for the schedule is also one you can defend in a security review.
Run cron as the web server PHP user
Run the CLI cron job as the same operating system user that PHP runs under for your site, such as the web server account on your distribution, so files written by cron (cache, temp and moodledata content) keep the ownership the web server expects. Avoid running cron as root, because a root-owned file in moodledata can break uploads and sessions later. Confirm the account has write access to moodledata and read access to the code, and nothing more. Check the user in your web server configuration before you write the crontab entry.
Keep cron.php and the CLI off the web
The CLI script admin/cli/cron.php is meant to run from the command line, not from a browser. Make sure your web server does not serve it, and confirm that the document root for your release points only at the public code path, which from Moodle 5.1 is the /public directory. A directory listing or a readable PHP file under the code tree can expose configuration details and gives an outsider a way to trigger work. Test by requesting the script over HTTP from outside your network and expecting it to be refused.
Disable web cron
Moodle can also trigger cron when a page is requested, which is the web cron approach. Once a system scheduler runs the CLI job, leave web cron disabled so that anonymous requests to the site cannot start background tasks or cause repeated heavy runs. Verify the setting in your site administration and in your deployment configuration so a later change does not switch it back on. Keep in mind that the site-level cron frequency check will still warn you if no scheduler is calling the job at the expected rate.
Control access to the crontab and logs
The crontab entry and any wrapper script that redirects output are part of your change record. Limit who can edit them to the administrators who manage the platform, and keep the script in version control or your configuration management so changes are reviewed. Cron output can contain file paths, database errors and task names, so store it where only operators can read it. Confirm the log directory is owned by the cron user and is not world-readable.
Retain cron output for investigation
Cron output is useful evidence when a task fails or a notification never arrives. Decide how long you keep it and rotate it with your standard logrotate policy or equivalent, so logs do not fill the disk that also holds moodledata. Record the time of each run and any non-zero exit codes, because those are what you will compare against when a user reports a missing message. Align retention with the rules your organization applies to operational logs, and confirm that choice with your compliance or records owner.
Alert when cron stops
A cron job that silently stops is one of the most common causes of a stalled Moodle site, because scheduled tasks, emails and cleanup all depend on it. Connect the status checks Moodle provides to your external monitoring, and add an alert on the absence of a recent run, not only on errors in the output. Test the alert by stopping the scheduler on a staging copy and confirming someone receives it within the time your operations team expects. Give the alert a named owner and a runbook.
How the scheduler, cron.php and the task queue interact
The diagram starts with the scheduler on a dedicated host, which runs the CLI cron script once a minute as the PHP user. That process runs due scheduled tasks and drains the ad hoc queue, recording task state in the database. A monitoring check then reads those results. The web-facing endpoint sits behind the trust boundary and should never run cron, so web cron stays off. Confirm the scheduler's user, and that the check reports recent runs.
Scheduler, CLI cron, task state and the status check, with the web endpoint kept outside cron.
Limits to confirm before you rely on cron in production
Cron looks simple on a single test server, but most production failures come from assumptions about the environment rather than from Moodle itself. The cards below cover the parts of the setup you must confirm in your own infrastructure. Check the Moodle release notes for the exact version you run before you set thresholds or schedules.
Exact PHP CLI and web user
Cron runs the PHP command line binary as a system user, which can differ from the PHP version and user that serve web requests. Confirm which php binary your scheduler calls, its version, and the user it runs as. Then check that this user owns or can write to the moodledata directory and can read config.php. A mismatch here causes files written by cron to become unreadable by the web server, which often shows up later as errors that look unrelated.
Overlapping run handling
If a cron run takes longer than the interval between runs, a scheduler that starts a new process without checking the old one can produce overlapping cron processes. Ask whether your scheduler prevents overlap with a lock file, a flock wrapper or a single-instance service. Also confirm what happens when the host reboots mid-run. Test this on a copy of the site by making a task run longer than the interval and watching the process list.
Container and Kubernetes behavior
In a container, there is no host crontab by default, and a CronJob may start a fresh pod each time. Confirm whether the job's pod can reach the database, the file store and the same moodledata volume as the web pods. Check that the schedule is set in the cluster's time zone, that failed jobs are retried or alerted, and that a concurrencyPolicy prevents overlapping runs. Also confirm that the container image includes the PHP extensions Moodle needs for CLI use.
Cron frequency warning threshold
Moodle's status checks report when cron has not run recently. The threshold and wording depend on the Moodle version, so do not copy a value from another site or an old guide. After go-live, open the status report and confirm it shows no cron warning, then check it again after a scheduler restart or a server patch. Record the version and threshold in your runbook so the next upgrade does not surprise the operations team.
Web cron kept disabled
Web cron calls the cron script over HTTP from a browser request, which spreads load across web nodes and can run the same task twice. Confirm that the web cron option is off in every environment, including staging copies that were cloned from production. Check the load balancer and any reverse proxy so that no external monitor or uptime check requests the cron URL. Only one cron mechanism should run the Moodle tasks.
Slow tasks that need tuning
Some scheduled tasks, such as log cleanup, report generation, backups and course-related jobs, can run long enough to delay others. Watch the task logs for a few cycles after go-live and identify tasks that regularly exceed your interval. Ask your team which tasks depend on your plugins, since third-party tasks are a common source of delay. Decide whether to tune their schedules, split the work across several cron processes, or move heavy jobs to a separate runner.
Common questions about Moodle cron setup
How long does Moodle cron setup take, and what drives the time?
Configuring cron on a single server is usually a short task, but the total time depends on how many servers run Moodle, whether a scheduler or system cron is already in use, and how much verification the change window requires. The main drivers are access to the server and its PHP CLI, the number of web nodes, whether the site already has monitoring for scheduled tasks, and how many scheduled and ad hoc tasks need checking after the first runs. Ask any partner for a written scope that lists the servers, the verification steps and the handover items, then confirm the timeline against your own change calendar.
Can a Moodle administrator set up cron alone?
Often yes, if the administrator has root or sudo access to the Moodle server, can run PHP from the command line as the web server user, and can read the Moodle logs. The work is a single crontab entry or a systemd timer that runs admin/cli/cron.php every minute, plus a check that web cron is disabled. Teams without Linux administration experience, or sites that run several web nodes behind a load balancer, usually need a systems engineer involved for the scheduler design and access controls. Confirm these points internally before deciding who does the work.
What does the work need from our team?
The work needs four things from your team: shell access to each Moodle server with permission to edit the scheduler, a PHP CLI that matches the web PHP version and runs as the correct user, access to the Moodle administration pages to check the cron status and task reports, and a way to watch the results over time. Monitoring can be Moodle's own check reports or an external tool that alerts when the cron heartbeat stops. Ask your team to confirm who owns the server, who receives alerts and who can approve a change to the scheduler.
Why does Moodle show a warning about the cron frequency?
Moodle shows a cron frequency warning when it detects that cron has not run as often as the platform expects, which delays notifications, scheduled tasks, course backups and other background work. The usual causes are a crontab that runs less often than every minute, web cron that depends on user visits, a PHP CLI path that is wrong, or a scheduler that fails silently. Check the scheduler log and the cron output for errors first, then confirm that the entry runs admin/cli/cron.php every minute as the correct user. Moodle's own documentation explains the expected frequency and the tasks it affects.
When do we need several cron processes on a larger site?
Several cron processes are needed when the ad hoc task queue grows faster than one cron run can clear it, for example when many long backups, course copies or large report jobs run at the same time. Moodle supports running more than one cron process so that queued work is picked up in parallel. The decision depends on task volume, the database and file storage capacity, and the time the queue takes to drain. Look at the ad hoc task queue and the logs before adding runners, and confirm the approach with your Moodle version's documentation before changing production.
What does a fixed-scope Moodle cron implementation include?
A fixed-scope engagement with DeployOpen is agreed in writing before work starts, so the scope, deliverables and timeline are fixed on paper. For a cron setup, that scope would typically cover the review of the current scheduler, the configuration of the system cron or scheduler entry, disabling web cron, verification of task runs and the cron frequency check, documentation for your operators, and any agreed handover. Any extra work, such as multi-node design or monitoring integration, should be named in the written scope. Ask for the list of deliverables and the verification evidence before you sign.
What should we ask for in a quote for this work?
Ask for the servers in scope, the scheduler method, the PHP user and CLI path, the verification steps, the monitoring hand-off and the documentation you will receive. Ask which parts are one-time and which recur, such as ongoing checks or retainer support for Moodle upgrades. Cost depends on the number of nodes, the access process inside your organization and the amount of verification required. A quote follows from the written scope, so compare proposals against the same list of servers and deliverables.

