6

I have a custom cron task that needs to be run every ten minutes. The task connects to remote servers to retrieve some data and update the drupal db.

In order to achieve that I have to execute drupal cron at least every 10 minutes (I do it via crontab on a GNU/Linux system), so my questions are :

  • Is it overkill to run drupal cron so frequently ?
  • What are the main tasks that drupal cron is executing ?
  • I understand that every task run within cron must check the last time it was executed so it is not run too frequently, is it generally understood this way ?
1
  • I think you split this one into 3 or more questions :) Dec 12, 2012 at 10:07

1 Answer 1

8

Is it overkill to run drupal cron so frequently ?

The answer to that is...it depends. If your cron task needs to run every 10 minutes, then no, it's not overkill. If it doesn't, then it is overkill. What you probably need is something like Elysia Cron, which lets you schedule cron jobs for specific modules on a an individual basis. That way you can run your custom labour-intense function as often as you need to without invoking the rest of the system's cron hooks.

What are the main tasks that drupal cron is executing ?

There's a list of core hooks that will be invoked on a cron run here, I don't think listing each one of those here would be prudent (there are 16 of them) - suffice say to say quite a lot happens; the caches are flushed which is probably a point of interest.

Bear in mind that many contrib modules also implement hook_cron(), so if you want an exhaustive list of functions that are invoked on cron you'll need to go through those files manually.

I understand that every task run within cron must check the last time it was executed so it is not run too frequently,

The must part of that is not true, there's no 'rule' for whether a task run on cron needs to check its last run time. There are plenty of situations where such a mechanism would be advantageous, but you absolutely don't need to do it. Again it depends on what each task is actually doing.

1
  • 1
    Running drupal cron every 10 minutes would probably be overkill, as some hook_cron() implementations are intensive (as you already say, caches will be cleared, in system_cron()). Even if you want to run a task every 10 minutes in 99% of the cases you won't want that to happen. Having Elysia Cron would certainly help here, as it could running the task outside of cron.
    – Pere
    Feb 25, 2014 at 15:24

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.