Index: cron.php =================================================================== RCS file: /cvs/drupal/drupal/cron.php,v retrieving revision 1.35 diff -u -F^f -r1.35 cron.php --- cron.php 5 Jul 2006 11:45:50 -0000 1.35 +++ cron.php 8 Aug 2006 18:35:49 -0000 @@ -3,29 +3,9 @@ /** * @file - * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs). + * Executing a cron run when accessed */ include_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - -// If not in 'safe mode', increase the maximum execution time: -if (!ini_get('safe_mode')) { - set_time_limit(240); -} - -// Check if the last cron run completed -if (variable_get('cron_busy', FALSE)) { - watchdog('cron', t('Last cron run did not complete.'), WATCHDOG_WARNING); -} -else { - variable_set('cron_busy', TRUE); -} - -// Iterate through the modules calling their cron handlers (if any): -module_invoke_all('cron'); - -// Clean up -variable_set('cron_busy', FALSE); -variable_set('cron_last', time()); -watchdog('cron', t('Cron run completed')); +drupal_cron_run(); Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.552 diff -u -F^f -r1.552 common.inc --- includes/common.inc 7 Aug 2006 15:04:13 -0000 1.552 +++ includes/common.inc 8 Aug 2006 18:35:50 -0000 @@ -1539,3 +1539,34 @@ function drupal_mail($mailkey, $to, $sub ); } } + +/** + * Executs a cron run when called + * @return + * Returns TRUE if ran successfully + */ +function drupal_cron_run() { + // If not in 'safe mode', increase the maximum execution time: + if (!ini_get('safe_mode')) { + set_time_limit(240); + } + + // Check if the last cron run completed + if (variable_get('cron_busy', FALSE)) { + watchdog('cron', t('Last cron run did not complete.'), WATCHDOG_WARNING); + } + else { + variable_set('cron_busy', TRUE); + } + + // Iterate through the modules calling their cron handlers (if any): + module_invoke_all('cron'); + + // Clean up + variable_set('cron_busy', FALSE); + variable_set('cron_last', time()); + watchdog('cron', t('Cron run completed.'), WATCHDOG_NOTICE); + + // Return TRUE so other functions can check if it did run successfully + return TRUE; +} Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.338 diff -u -F^f -r1.338 system.module --- modules/system/system.module 7 Aug 2006 19:35:41 -0000 1.338 +++ modules/system/system.module 8 Aug 2006 18:35:51 -0000 @@ -17,15 +17,17 @@ function system_help($section) { switch ($section) { case 'admin/help#system': $output = '

'. t('The system module provides system-wide defaults such as running jobs at a particular time, and storing web pages to improve efficiency. The ability to run scheduled jobs makes administering the web site more usable, as administrators do not have to manually start jobs. The storing of web pages, or caching, allows the site to efficiently re-use web pages and improve web site performance. The settings module provides control over preferences, behaviours including visual and operational settings.') .'

'; - $output .= '

'. t('Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). The aggregator module periodically updates feeds using cron. Ping periodically notifies services of new content on your site. Search periodically indexes the content on your site. Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.') .'

'; + $output .= '

'. t('Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). The aggregator module periodically updates feeds using cron. Ping periodically notifies services of new content on your site. Search periodically indexes the content on your site. Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution. Cron can, if necessary, also be run manually.') .'

'; $output .= '

'. t('There is a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, the system module does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server\'s load. Only pages requested by anonymous users are cached. In order to reduce server load and save bandwidth, the system module stores and sends cached pages compressed.') .'

'; $output .= t('

You can

-', array('%file-cron' => 'cron.php', '%external-http-drupal-org-cron' => 'http://drupal.org/cron', '%admin-settings' => url('admin/settings/page-caching'))); +', array('%file-cron' => 'cron.php', '%external-http-drupal-org-cron' => 'http://drupal.org/cron', '%cron-status' => url('admin/settings/cron-status'), '%cron-manually' => url('admin/settings/cron-status/cron'), '%admin-settings' => url('admin/settings/page-caching'))); $output .= '

'. t('For more information please read the configuration and customization handbook System page.', array('%system' => 'http://drupal.org/handbook/modules/system/')) .'

'; return $output; case 'admin/settings/modules#description': @@ -227,7 +229,7 @@ function system_menu($may_cache) { $items[] = array( 'path' => 'admin/settings/cron-status', 'title' => t('cron status'), - 'description' => t('View whether or not cron is running on your site.'), + 'description' => t('Check cron status or run cron manually.'), 'callback' => 'system_cron_status'); $items[] = array( 'path' => 'admin/settings/clean-urls', @@ -751,18 +753,29 @@ function system_unicode_settings() { return system_settings_form('system_unicode_settings', unicode_settings()); } -function system_cron_status() { - $cron_last = variable_get('cron_last', NULL); - - if (is_numeric($cron_last)) { - $status = t('Cron is running. The last cron job ran %time ago.', array('%time' => format_interval(time() - $cron_last))); - } - else { - $status = t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for configuring cron jobs.', array('%url' => 'http://drupal.org/cron')); +function system_cron_status($cron = '') { + if ($cron == 'cron') { + // Run cron manually + if(drupal_cron_run()) { + drupal_set_message(t('Cron ran successfully')); + } + else { + drupal_set_message(t('Cron run failed')); + } + drupal_goto('admin/settings/cron-status'); } - return $status; -} + $cron_last = variable_get('cron_last', NULL); + if (is_numeric($cron_last)) { + $status = t('Cron is running. The last cron job ran %time ago.', array('%time' => format_interval(time() - $cron_last))); + } + else { + $status = t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for configuring cron jobs.', array('%url' => 'http://drupal.org/cron')); + } + $status .= ' '.t('Cron can, if necessary, also be run manually.', array('%cron' => url('admin/settings/cron-status/cron'))); + + return $status; + } /** * Checks the existence of the directory specified in $form_element. This