Keep scheduled tasks running: cron entries and the job runner
Expiring stories, rebuilding statistics and scheduled promotions all rely on XenForo running tasks in the background. How that works, and how to make it reliable.
Updated 4 min read By the D.C Style team
On this page
XenForo does a lot of work in the background: sending alerts, rebuilding caches, expiring content, cleaning up logs. Add-ons add their own background tasks too. All of it runs through XenForo's job system, and by default that system only runs when people visit your forum. On a busy forum you never notice. On a quiet one, scheduled tasks can run late, and features that depend on them look broken. This guide explains how it works and how to make it reliable.
Cron entries: XenForo's timetable
A cron entry is a task with a schedule, such as "every hour" or "every day at 03:00". Open Tools > Cron entries to see them all, with the time each one will run next under Next run.
D.C Style add-ons add their own entries here. A few examples:
| Cron entry | What depends on it |
|---|---|
| DC/Story: Expire stories | Stories disappearing after their time is up. |
| DC/ForumStats: Rebuild statistics cache | Fresh numbers in Forum Statistics. |
| D.C Style - Handle scheduled widget promotions | Scheduled thread promotions starting and ending on time. |
| Sync local cached files to Google Drive | Google Drive Attachments' cache mode moving files to Drive. |
| Login as user: close abandoned sessions | Login As User ending sessions nobody closed. |
Each entry has a Run now control. Use it to test a task, or to catch up straight away instead of waiting for the next run. An entry that belongs to a disabled add-on cannot run until that add-on is enabled again.
The job runner: what actually runs the tasks
When a cron entry is due, XenForo does not run it on the spot. It queues it as a job, alongside other deferred work such as sending alerts or rebuilding caches. The Job run trigger decides when the queue is processed. You will find it in Setup > Options > System and performance. It is an advanced option, so click Show advanced options on the Options page if you cannot see it.
- Activity based trigger (the default): jobs run as visitors browse the forum. There is nothing to set up, but if nobody visits for a few hours, nothing runs for a few hours either.
- Server based trigger: your server runs the jobs once a minute, whether anyone is visiting or not. It needs one line of setup, below.
Switching to the server based trigger
This is the most reliable setup, and we recommend it for any forum that uses scheduled features. Your host's control panel usually has a "Cron jobs" page. Ask your host if you cannot find it.
- Add a cron job that runs every minute with this command, replacing the path with the real path to your forum:
In a crontab, the full line looks like this:php /path/to/xf/cmd.php xf:run-jobs* * * * * php /path/to/xf/cmd.php xf:run-jobs - Wait a few minutes, then check Tools > Cron entries. The Next run times should be moving forward.
- Only then switch Job run trigger to Server based trigger and save.
Warning: Do not switch to the server based trigger before the server cron job is working. If nothing runs the command, no jobs run at all: no alerts, no cache rebuilds, no scheduled tasks.
Tip: Run the command as the same user your web server uses, or files the jobs create may end up with permissions the web server cannot change later. Your host can tell you which user that is.
Signs that scheduled tasks are not running
- Stories stay up long after they should have expired.
- Forum Statistics shows the same numbers all day.
- Scheduled promotions in D.C Style Widgets never start or end.
- The Next run times in Tools > Cron entries are in the past.
If you see these, check the job trigger first, then look for errors in Logs > Server error log. A task that fails keeps failing until the error is fixed. How to read the server error log. A reliable job runner also helps a busy forum feel faster: see Speed up your XenForo forum.
Still stuck? Open a support ticket with the name of the cron entry, its Next run time, and any related entry from the server error log.