--- cron.php 2005-03-20 11:03:12.000000000 +0100 +++ runcron.php 2005-03-20 11:03:16.000000000 +0100 @@ -3,6 +3,18 @@ /** * @file * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs). + * Recognizes the parameters 'include' and 'exclude' with a comma separated list of module names + * + * Examples: + * + * runs all hooks + * http://mysite.com/cron.php + * + * runs all hooks except the search and aggregator modules + * http://mysite.com/cron.php?exclude=search,aggregator + * + * runs only search, archive and aggregator modules + * http://mysite.com/cron.php?includ=search,archive,aggregator */ include_once 'includes/bootstrap.inc'; @@ -15,24 +27,37 @@ // Check if the last cron run completed if (variable_get('cron_busy', false)) { - watchdog('cron', t('Last cron run did not complete.')); + watchdog('cron', t('Last cron run did not complete.'), WATCHDOG_WARNING); } else { variable_set('cron_busy', true); } -$modules = explode(',', $_GET['modules']); -print_r($modules); -exit(); -foreach ($modules as $module) { - module_invoke($module, 'cron'); +// initialize $modules +$modules = array(); + +// handle a list of modules to exclude +if ($_GET['exclude']) { + $modules = module_list(); + $exclude = explode(',', $_GET['exclude']); + $modules = array_diff($modules, $exclude); +} +// handle a list of modules to include +else if ($_GET['include']) { + $modules = explode(',', $_GET['include']); +} +// in the absence of excludes or includes run all +else { + $modules = module_list(); } -// Iterate through the modules calling their cron handlers (if any): -module_invoke_all('cron'); +// invoke cron for each of the modules in $modules +foreach ($modules as $key => $module) { + module_invoke($module, 'cron'); +} // Clean up variable_set('cron_busy', false); -watchdog('cron', t('Cron run completed')); +watchdog('cron', t('Cron run completed. Modules included: '). implode(', ', $modules)); ?>