summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-09 07:42:55 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-09 07:42:55 +0000
commit37469a8df4e754327c24b3cf29b3c1e79d0caaf8 (patch)
tree11b83c7714485742a18af5584a7953d277c315df
parent3c975f4bb8d3975dc73444e47d01dd98e9b2b37a (diff)
downloadbrdo-37469a8df4e754327c24b3cf29b3c1e79d0caaf8.tar.gz
brdo-37469a8df4e754327c24b3cf29b3c1e79d0caaf8.tar.bz2
- Patch #76958 by forngren, dww et al: make it a tad easier to run cron manually.
-rw-r--r--cron.php22
-rw-r--r--includes/common.inc31
-rw-r--r--modules/system/system.module23
3 files changed, 50 insertions, 26 deletions
diff --git a/cron.php b/cron.php
index cdc0b45c5..f242ee782 100644
--- a/cron.php
+++ b/cron.php
@@ -8,24 +8,4 @@
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();
diff --git a/includes/common.inc b/includes/common.inc
index 934f8a829..af3371cc2 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1539,3 +1539,34 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar
);
}
}
+
+/**
+ * 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;
+}
diff --git a/modules/system/system.module b/modules/system/system.module
index 89d6a7bef..7ad3a891a 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -17,15 +17,17 @@ function system_help($section) {
switch ($section) {
case 'admin/help#system':
$output = '<p>'. 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.') .'</p>';
- $output .= '<p>'. 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.') .'</p>';
+ $output .= '<p>'. 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.') .'</p>';
$output .= '<p>'. 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 <em>anonymous</em> users are cached. In order to reduce server load and save bandwidth, the system module stores and sends cached pages compressed.') .'</p>';
$output .= t('<p>You can</p>
<ul>
<li>activate your cron job on the cron page <a href="%file-cron">cron.php</a>.</li>
<li>read how to <a href="%external-http-drupal-org-cron">configure cron jobs</a>.</li>
<li>administer cache settings in <a href="%admin-settings">administer &gt;&gt; site configuration &gt;&gt; page caching</a>.</li>
+<li><a href="%cron-status">view</a> whether or not cron is running on your site.</li>
+<li>run cron <a href="%cron-manually">manually</a>.</li>
</ul>
-', 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 .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%system">System page</a>.', array('%system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
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,15 +753,26 @@ function system_unicode_settings() {
return system_settings_form('system_unicode_settings', unicode_settings());
}
-function system_cron_status() {
- $cron_last = variable_get('cron_last', NULL);
+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');
+ }
+ $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 <a href="%url">configuring cron jobs</a>.', array('%url' => 'http://drupal.org/cron'));
}
+ $status .= ' '. t('Cron can, if necessary, also be run <a href="%cron">manually</a>.', array('%cron' => url('admin/settings/cron-status/cron')));
return $status;
}