I recently had a problem where my web provider told me that I was using up too much CPU. In the process of tracking this issue down, I wrote a "progress indicator" for poormancron that logs the call to each module's cron hook via watchdog. This way, you can determine if a single module is taking too long to run, or even if poormanscron is being killed for too much CPU usage. Here's the code for poormanscron_exit():

//
// Call cron hooks on all modules
//
$modules = module_list();
foreach ($modules as $key => $value) {
   if (module_hook($key, 'cron')) {
      if (variable_get('poormanscron_log_cron_runs', 1) == 1) {
         watchdog('cron', "Calling ${key}_cron()...", WATCHDOG_NOTICE);
      }
      module_invoke($key, 'cron');
   }
}

Hope you find this useful!

-- Doug

Comments

Uwe Hermann’s picture

Version: 4.6.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » Uwe Hermann
Status: Needs review » Fixed

Fixed in CVS, thanks. I implemented this slighty different and now also log the number of seconds every function needed. I also made this optional, the default is "off". Use administer -> settings -> poormanscron to enable the feature. Please reopen the issue if there are problems...

Anonymous’s picture

Status: Fixed » Closed (fixed)