ProcessCronJobs by Neue Rituale

Manages the execution of CronJobs


What it does

The module provides paths under which cronjobs can be registered. It lists all registered cronjobs and can execute individual ones manually. The last execution, the last status and, in the event of an error, the last error message are displayed.


  • Clear overview of all registered CronJobs
  • Easy to set timing (onInit or onReady) and delay (LazyCron)
  • Individual path (endpoint) that executes the CronJobs. Configuration of a secret path segment and additional path segments (namespaces) for selected CronJobs.
  • Display of the time of the last execution and any error messages


  1. Copy the files for this module to /site/modules/ProcessCronJobs/
  2. In admin: Modules > Refresh. Install ProcessCronJobs.
  3. Go to Setup > CronJobs
  4. Copy and Install example Module (modules/ProcessCronJobs/example/ProcessCronJobsRegistration.module.example) to register your CronJobs in the __constructor() method. You can also use any other __constructor() method. It makes sense to register the CronJobs as early as possible so that they can also be executed on onInit.
  5. Set up the real cron that calls the ProcessCronJobs provided endpoint.

Install via composer

  1. Execute the following command in your website root directory.
    composer require nr/processcronjobs

Register a CronJob


A simple example for registering a CronJob.

wire()->addHookBefore('ProcessCronJobs::register', function(HookEvent $event){
	/** @var ProcessCronJobs $processCronJobs */
	$processCronJobs = $event->object;
		function(CronJob $cron){ echo "Hello Cron"; },


This CronJob should run once a day at init.

wire()->addHookBefore('ProcessCronJobs::register', function(HookEvent $event){
	/** @var ProcessCronJobs $processCronJobs */
	$processCronJobs = $event->object;
		function(CronJob $cron){ echo "What a beautiful day"; },
			'lazyCron' => 'LazyCron::everyDay',
			'timing' => CronJob::timingInit,

Long Running

This CronJob runs for a very long time and is called directly by a "real" CronJob so as not to block other CronJobs. The endpoint for this CronJob is or

CronJobs that have a namespace (own path segment) cannot be delayed with LazyCron, because LazyCron can only be started by a single request. LazyCron creates a lock file and thus blocks the execution of parallel calls.

wire()->addHookBefore('ProcessCronJobs::register', function(HookEvent $event){
	/** @var ProcessCronJobs $processCronJobs */
	$processCronJobs = $event->object;
		function(CronJob $cron){ echo "I have so much work to do"; },
			'timing' => CronJob::timingInit,
			'ns' => 'longrunning'

Process View



Modules > Configure > ProcessCronJobs

You will find the following configuration options in the module settings:

  • The trigger path, i.e. the path that triggers the CronJob processing, can be adjusted here (default: cron/).
  • A secret path segment can be created that must be appended to the trigger path so that processing is started.
  • Automatic processing can generally be stopped (status).
  • The cache of ProcessCronJobs can be emptied. Things like the time of the last call, the status of the last call and possibly an error message are stored in the cache.


The CronJob object

nameStringUnique name in PascalCase e.g. MyFirstCronJob.
callbackCallablefunction(CronJob $cron){}Function to be executed
lazyCronnull, StringnullIf empty, the CronJob is executed without delay as soon as the path is called.
nsnull, StringnullIf empty, the CronJob is called via the default path.
timingIntegerCronJob::timingReadyThe CronJon can be called either at onInit (1) or onReady (2). OnInit is earlier and therefore faster, but not all functions of ProcessWire are available here, e.g. page and language.
timingStrStringonReadyThis is just a getter property.
disabledBooleanfalseThis can be used to deactivate the cronjob, e.g. disabled = $config->debug.
triggerIntegerCronJob::triggerNeverDisplays the last trigger for execution. Possible values are:
1 (Never): CronJob has never been executed
2 (Auto): CronJob was last executed directly via the "real" Cron (onDemand).
4 (Lazy): CronJob was called up with a time delay via the LazyCron.
8 (Force): The CronJob was started manually
16 (Error): The last call ended with an error (see log).
triggerStrStringUnknownThis is just a getter property.
lastRunInteger0Contains the last execution time as a Unix timestamp. Stored and retrieved in the ProcessWire cache.
lastErrorStringPossible error message from the last call

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #499
    In the 499th issue of ProcessWire Weekly we'll check out the latest weekly update from Ryan, introduce a new third party module called RockPdf, and more. Read on! / 3 December 2023
  • Using date range fields in ProcessWire
    This week we'll take a detailed look at the newest addition to the ProFields set of modules: the Date Range Fieldtype and Inputfield.
    Blog / 24 November 2023
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer