Anyone who's worked with Drupal a while knows how frustrating it can be trying to debug problems with cron.

The problem is, there's no way of knowing which module is running cron, how long it runs for and at which point cron is failing across all the available hook_cron implementations.

The attached patches provide a "debug mode" checkbox on the admin cron settings form which records detailed timing information about cron runs for each module, to the watchdog - when enabled.

I've been successfully using this patch for a while now to debug cron and have found it very helpful, as have many others on irc. and would like to commit it to benefit others.

Please review, provide any feedback and commit if possible.

cheers,

David

P.S Drupal rocks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidwhthomas’s picture

FileSize
165.4 KB

The attached screenshot shows sample logging information under recent log entries for cron.

davidwhthomas’s picture

More up-to-date screenshots

tstoeckler’s picture

Reposting from the other issue:
If this can be done from contrib, I think it would be a useful feature for the Devel module.

davidwhthomas’s picture

Thanks for the suggestion.

Although it would be convenient for regular users to be able to switch this debug mode on / off in core, looking at putting it into devel as a contrib module or patch is a reasonable approach too.

I will look into this and follow it up with the Devel maintainers.

davidwhthomas’s picture

Note, I'm still interested in getting this into core, if there's interest from others..

brianV’s picture

FileSize
3.55 KB

I really like this idea, and have rolled a D8 patch to implement it.

That said, I don't necessarily agree that we should call it a 'debug mode'. I believe referring to it as a timer is more precise. It's also useful for more than simply debugging.

I've also rounded the time to four positions rather than two, as for very short operations, the timer often shows 0 seconds.

brianV’s picture

Title: Enable optional cron debug logging » Optional timing and logging of cron jobs.

Re-titling

Status: Needs review » Needs work

The last submitted patch, 1143082-cron_timer.patch, failed testing.

brianV’s picture

Status: Needs work » Needs review

#6: 1143082-cron_timer.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1143082-cron_timer.patch, failed testing.

brianV’s picture

Status: Needs work » Needs review

#6: 1143082-cron_timer.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1143082-cron_timer.patch, failed testing.

brianV’s picture

Status: Needs work » Needs review

#6: 1143082-cron_timer.patch queued for re-testing.

brianV’s picture

Fifth time is the charm - no random testbot implosions...

Status: Needs review » Needs work

The last submitted patch, 6: 1143082-cron_timer.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Dane Powell’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

The functionality and patch in this thread have basically been implemented already in #2716073: Improve cron logging and #2823543: Make cron execution logging optional