• We've added extra Spam Protection. if you get problem with account registration / registration rejected. please contact us

CLI Job Runner 1.3.1

No permission to download
Compatible XF 2.x versions
  1. 2.0
  2. 2.1
Visible branding
This XenForo 2.0 addon disables the browser triggered job runner and implements a CLI triggered job runner for use with Unix cron.


This addon requires PHP 5.4 or higher and only works on XenForo 2.0.x


Install as per normal addon installation.

Note: once this addon is installed and activated, scheduled tasks will no longer run - so completing the remaining installation steps is critical to ensure your forum continues to function normally.

First, you should test that your job runner is functioning - execute the following command from your CLI:

$ php <path to your forum root>/cmd.php xf:run-jobs

For example, if your forum root is /srv/www/xenforo/community, then the job runner command would be:

$ php /srv/www/xenforo/community/cmd.php xf:run-jobs

Running this command will execute any outstanding jobs and then finish with a message about whether there are more jobs waiting to be executed or not. When executing this command from cron, it is recommended that you use the --quiet (or -q) flag to suppress output.

Once you are happy that the job runner functions, you will need to create your own cron task to run it on a schedule of your choosing.

It is highly recommended that you have your cron task run as the web server user to prevent potential permission problems.

For example, on Ubuntu with a web server user of www-data, install a cron task by running the following command:

$ sudo crontab -u www-data -e

Edit the crontab file and add:

* * * * * php <path to your forum root>/cmd.php --quiet xf:run-jobs

Save the crontab.

This will execute the job runner every minute, checking for outstanding jobs to be run.

By default, the job runner will run for a maximum of 30 seconds, executing any outstanding jobs until there are no more runnable jobs in the queue.


You may adjust the maximum execution time of the job runner by specifying the --time=[TIME] option on the command line.

For example, to allow the job runner to execute for a maximum of 45 seconds:

$ php <path to your forum root>/cmd.php --time=45 xf:run-jobs

It is not recommended that you allow the job runner to run for longer than the period between cron triggers. For example, the above cron task example will execute the job runner every minute, so setting the maximum run time to more than 60 is generally a bad idea.

If you prefer to not run the cron task as frequently as once per minute, you can adjust the cron job as
required and if you do, you may also want to allow the job runner task to run for longer than the default 30 seconds to ensure that all outstanding work is completed.

For example, to run the cron task every 5 minutes, allowing the job runner to execute for a maximum of 4 minutes, use the following cron command:

*/5 * * * * php <path to your forum root>/cmd.php --quiet --time=240 xf:run-jobs

For further customisation of your job execution, you may also adjust the maximum time that each job is permitted to run.
This is configured via a XenForo config.php Option:

$config[jobMaxRunTime'] = 8;

The jobMaxRunTime option configures the amount of time in seconds that processing jobs will be allowed to run before they are suspended for further processing on another go-around, if possible. The default setting is optimised for the browser-triggered job runner and so to allow jobs to execute longer in a CLI environment, you may want to adjust this to a higher value.

You should not set jobMaxRunTime to anything higher than 30 seconds, or the time specified by the --time option. In general it is suggested that this setting be kept to a relatively small value to avoid the situation where a single very long job may prevent other jobs from executing in a timely manner. Some experimentation may be required to find the optimal value for your server load and forum size.
First release
Last update
4.50 star(s) 2 ratings

More resources from Admin

Latest updates

  1. v1.3.1

    New features: implemented debug logger for Job execution time tracking extend the XF\Job\Cron...
  2. v1.2.0

    Thanks to @Xon for identifying the bug fix where AJAX JSON responses would still trigger...
  3. 1.1.0

    changes: new icon bug fix: should return 0 for successful execution new feature: show-jobs command
  4. v1.0.1

    Minor update for XF2.0 and now tested on XF2.1 we still want to run jobs if the user has...
  5. Re-release

    Same version, new addon_id. If you already have v1.0.0 installed, there is no need to upgrade...