The hook_cron_alter(&$hooks) allows you to change the cron hooks defined by hook_cron() and hook_cronapi().
Change default rules for the Node modules cron hook and hi-jack system cron:
function hook_cron_alter(&$hooks) { $hooks['node_cron']['settings']['rules'] = array('0 * * * *'); $hooks['system_cron']['module'] = 'mymodule'; $hooks['system_cron']['callback'] = 'mymodule_new_system_cron'; $hooks['system_cron']['file'] = drupal_get_path('module', 'mymodule') . '/mymodule.cron.inc'; }
Example of the Node modules cron hook data:
( [unsafe] => [description] => Default cron handler [module] => node [configure] => [settings] => Array ( [enabled] => 1 [rules] => Array ( [0] => * * * * * ) [catch_up] => 300 ) [function] => node_cron [callback] => node_cron )
Name | Description |
---|---|
unsafe | If true, then the cron hook is considered unsafe, meaning that Ultimate Cron will not execute it. This value is set by Ultimate Cron when determining which hooks are unsafe. A hook is considered unsafe, if the function resides in a module with a weight lower than Ultimate Cron. |
description | The description of the cron hook, usally defined in hook_cronapi(). The core modules description are added through a hook_cron_alter() in Ultimate Cron. |
module | Name of the module in which the cron hook lives |
configure | Link to module settings page |
settings | Array with settings data, contains enabled, rules and catch_up by default, provided by Ultimate Cron |
function | Name of function for the cron hook. Note: This is unsafe to change |
callback | Name of callback to use when executing cron. This is set to the cron hooks function by default |
file | Path to file (including filename) where callback is defined. |