4

Is this possible to find out which cron jobs are currently running?

  • What you meant by "which cron job" exactly ? – AyeshK Oct 28 '12 at 0:12
  • I want to know if there are any cron jobs running at the moment, possibly including a start time – uwe Oct 28 '12 at 0:52
4

The answer can be found in drupal_cron_run. While it is the case that you can tell if Cron is currently running by calling lock_acquire('cron', ...)), just as Drupal does (don't forget to call lock_release too), Drupal does not in any way set any information about the individual cron hooks that it executes during a cron job.

If you need more control over cron job execution, you could always copy the drupal_cron_run function into your own module and modify it to suit. drush_core_cron() does nothing other than call drupal_cron_run, so you could call your own cron function via drush ev 'mymodule_cron_run();' from your crontab. If you did this, you would need to review the implementation of drupal_cron_run on every update of Drupal core, and check for any significant alterations in behavior, so you should only customize cron if it's really important that you do so.

  • And if you want to fire specific cron function (which is not recommended to do so IMO), just call MYMODULE_cron(). – AyeshK Oct 28 '12 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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