5

Drupal 6 possible noob question. Is there a way to get a list of cron tasks from the Drupal 6 Admin? I am a themer for the site. The original dev is long gone. Everyone complains of slowness and 500.shtml errors. I looked in the log and noticed that these are most often associated with a cron task that runs hourly. But I can't see what those jobs are. Once I get the list is there also a way to disable unneeded tasks from within Drupal?

I'm running Windows on my client machine. I don't have DRUSH.

Thanks In Advance

2
  • 1
    If you by chance happen to have Elysia Cron installed, you may be able to get a good enough idea through its admin interface, otherwise you basically will have to look through your modules' source code and look for hook_cron(), eg, `function MODULENAME_cron()' and then see what's happening in each.
    – Jimajamma
    Aug 13, 2013 at 21:35
  • Try this module. drupal.org/project/ultimate_cron. The Ultimate Cron handling for Drupal. Runs cron jobs individually in parallel using configurable rules, pool management and load balancing. It is like Elysia cron in D7 Aug 4, 2017 at 12:25

3 Answers 3

3

If you don't have Elysia Cron installed, and from a purely debugging standpoint, if you want or need to see what module's cron is running, as well as how long it is taking to run, you can TEMPORARILY edit includes/common.inc's drupal_cron_run() function like so...

// Iterate through the modules calling their cron handlers (if any):
// module_invoke_all('cron'); // watchdog how long each hook takes now...

$details='';
foreach (module_implements('cron') as $module) {
  $start=microtime(TRUE);
  $function = $module . '_cron';
  $function();
  $finish=microtime(TRUE);
  $duration=$finish - $start;
  $details.='<pre>' . $module . ': ' . $duration . ' seconds</pre>';
}

// Record cron time
variable_set('cron_last', time());
watchdog('cron', 'Cron run completed.' . $details, array(), WATCHDOG_NOTICE); // . in $details here :)

eg, comment out the module_invoke_all() and instead loop through via module_implements() and log how long each individual cron run takes.

3
  • Can I just add the Elysia module? I looked in the cPanel and the cron from Drupal is executing hourly. Will Elysia give me details on what -Drupal- is doineg every hour? All I see is a wget. A lot of the 500 errors we get occur right after this.
    – jchwebdev
    Aug 21, 2013 at 5:28
  • Does this trick apply for D7 too?
    – cdmo
    Jan 8, 2014 at 20:06
  • D7 does it a bit differently but sure, you could add some microtime()s to its version temporarily as well.
    – Jimajamma
    Jan 8, 2014 at 20:17
8

Or simple use

drush ev 'var_dump(module_implements("cron"))'

For list the cron job that exists.

3
  • Hello and welcome. This provide an answer, but is now formatted in a way that makes it look like a comment. Could you please edit it to make it look like a standalone entity and not a voice in conversation? This is Q&A site and not a forum, after all :)
    – Mołot
    Oct 11, 2013 at 6:49
  • This only tells you which modules have a cron installed, which is a nice start, but it'd be nicer to see exactly what each individual task was.
    – cdmo
    Jan 8, 2014 at 20:09
  • This returned an error while having Drupal 10 installed locally with DDEV: Error: Call to undefined function module_implements() in eval() (line 1 of /var/www/html/vendor/drush/drush/src/Commands/core/PhpCommands.php(32) : eval()'d code).
    – kopeboy
    Jul 4 at 15:38
5

For Drupal 8/9, you can simply use the following command:

drush php-eval 'var_dump(\Drupal::moduleHandler()->getImplementations("cron"))'
1
  • This returned an error while having Drupal 10 installed locally with DDEV: Error: Call to undefined function module_implements() in eval() (line 1 of /var/www/html/vendor/drush/drush/src/Commands/core/PhpCommands.php(32) : eval()'d code).
    – kopeboy
    Jul 4 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.