The Ultimate Cron handling for Drupal.
Runs cron jobs individually in parallel using configurable rules, pool management and load balancing.
8.x-2.x
This is a port of the 7.x-2.x branch to Drupal 8, using config entities and the Drupal 8+ plugin system.
See https://befused.com/drupal/ultimate-cron/ for an overview on how the module works and how to discover jobs.
2.9 READY!
Ultimate Cron 7.x-2.9 is out now.
Ultimate Cron 1.x documentation can be found at https://drupal.org/node/1666944
The old project page for Ultimate Cron 1.x can be found at https://drupal.org/node/2195381
Changes
- No more dependency to Background Process. Ultimate Cron now works without Background Process. However, Background Process is still supported for true parallelism
- Refactored to use cTools plugins, making it easier to extend Ultimate Cron.
- Now includes the daemonizer and queue throttling features, previously found in the modules Ultimate Cron Daemonizer and Ultimate Cron Queue Scaler
- Hopefully a more robust lock and logging mechanism.
- Integration with nodejs for live update on cron page
- Nagios support has not been re-implemented
Upgrade path from 7.x-1.x and previous
Upgrading from an earlier version of Ultimate Cron to a 7.x-2.x version has some caveats. See the documentation.
Plugins
Ultimate Cron is built upon 4 plugin types.
- Settings: - plugins that provide custom settings for jobs (bundled: general, queue).
- Schedulers: - plugins that provide a mechanism for whether or not a job should run at a certain time (bundled: simple, crontab).
- Launchers: - plugins that provide a way of launching jobs (bundled: serial, background_process).
- Loggers: - plugins that provide a logging backing for job status (bundled: database, cache).
Ultimate Cron 7.x-2.x documentation can be found at https://drupal.org/node/2195383
Features
- Works out-of-the box in most cases (or aims to)
- Parallel execution of cron jobs
- Configuration per job (enable/disable, rules, etc.)
- Multiple rules per cron job
- Pool management and load balancing using Background process
- Support for Drupal Queues
- Overview of cron jobs
- Log history of cron jobs
- Status/error messages per cron job, providing easy debugging of troublesome cron jobs
- Uses hook_cronapi() (Elysia Cron compatible, NOT 2.x, please use hook_cron_alter() for similar functionality)
- hook_cron_alter() for easy adding/manipulating cron jobs
- Poormans cron with keepalive a granularity of 1 minute
- Drush support (list, start, enable/disable jobs from the command line)
Dependencies
Supported 3rd party modules
Caveats
- Logging can be quite extensive for some. This can be controlled via Watchdog Filtering
Declaring new cron jobs
From ultimate_cron.api.php
<?php
/**
* Inform Ultimate Cron about cron jobs.
*
* Note that the result of this hook is cached.
*
* @return array
* Array of cron jobs, keyed by name.
* - "title": (optional) The title of the cron job. If not provided, the
* name of the cron job will be used.
* - "file": (optional) The file where the callback lives.
* - "module": The module where this job lives.
* - "file path": (optional) The path to the directory containing the file
* specified in "file". This defaults to the path to the module
* implementing the hook.
* - "callback": (optional) The callback to call when running the job.
* Defaults to the job name.
* - "callback arguments": (optional) Arguments for the callback. Defaults
* to array().
* - "enabled": (optional) Initial state of the job. Defaults to TRUE.
* - "tags": (optional) Tags for the job. Defaults to array().
* - "settings": (optional) Default settings (plugin type) for this job.
* Example of a job declaring some default settings for a plugin called
* "some_plugin":
* 'settings' => array(
* 'some_plugin' => array(
* 'some_value' => 60,
* ),
* ),
* - "scheduler": (optional) Default scheduler (plugin type) for this job.
* Example of a job using the crontab scheduler as default:
* 'scheduler' => array(
* 'name' => 'crontab',
* 'crontab' => array(
* 'rules' => array('* * * * *'),
* ),
* ),
* - "launcher": (optional) Default launcher (plugin type) for this job.
* Example of a job using the serial launcher as default:
* 'launcher' => array(
* 'name' => 'serial',
* 'serial' => array(
* 'thread' => 'any',
* ),
* ),
* - "logger": (optional) Default logger (plugin type) for this job.
* Example of a job using the cache logger as default:
* 'logger' => array(
* 'name' => 'cache',
* 'cache' => array(
* 'bin' => 'mycachebin',
* ),
* ),
*/
function hook_cronapi() {
$items = array();
$items['example_my_cron_job_1'] = array(
'title' => t('This is my cron job #1'),
'file' => 'example.jobs.inc',
'file path' => drupal_get_path('module', 'example') . '/cron',
'callback' => 'example_my_cron_job_callback',
'callback arguments' => array('cronjob1'),
'enabled' => FALSE,
'tags' => array('example'),
'settings' => array(
'example_plugin' => array(
'example_setting' => 'example_value',
),
),
'scheduler' => array(
'name' => 'crontab',
'crontab' => array(
'rules' => array('* * * * *'),
),
),
'launcher' => array(
'name' => 'serial',
'serial' => array(
'thread' => 'any',
),
),
'logger' => array(
'name' => 'cache',
'cache' => array(
'bin' => 'my_cache_bin',
),
),
);
return $items;
}
?>
In fact, all options are optional, so the most minimal way of declaring a new cronjob is:
<?php
/**
* Implements hook_cronapi().
*/
function example_cronapi() {
$items = array();
$items['example_my_cron_job'] = array();
return $items;
}
/**
* The callback for the cron job,
*/
function example_my_cron_job($job) {
}
?>
Related modules
Project information
- Module categories: Administration Tools, Developer Tools, Performance
- 50,866 sites report using this module
- Created by gielfeldt on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Bugfixes, PHP compatibility and minor improvements
Development version: 8.x-2.x-dev updated 4 Feb 2024 at 09:09 UTC
Development version: 7.x-2.x-dev updated 23 Oct 2022 at 21:34 UTC