Sign up ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I've been searching around, but I can not find a good explanation (or understanding) what the 'time' value in hook_cron_queue_info actually does, or how to set it to work properly.


it is said that: 'time': (optional) How much time Drupal should spend on calling this worker in seconds. Defaults to 15.

I don't quite understand that. Does calling the worker mean time allowed to execute the cron queue job? And does the next cron queue job starts after this time? Or when the previous job is completed?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

It's literally what the description says it is - during a cron run, Drupal will spend a maximum of the seconds you provide in that value processing that particular queue, regardless of the number of jobs in it.

If you're looking for the relevant code it's in drupal_cron_run()

foreach ($queues as $queue_name => $info) {
  if (!empty($info['skip on cron'])) {
    // Do not run if queue wants to skip.
  $function = $info['worker callback'];
  $end = time() + (isset($info['time']) ? $info['time'] : 15);
  $queue = DrupalQueue::get($queue_name);
  while (time() < $end && ($item = $queue->claimItem())) {
share|improve this answer
Thanks Clive.I can see where my mix up was. I thought it was time allowed doing ONE job (thinking in case of server time outs). Now I know it is time allowed to do a batch of jobs. – Quentin Campbell Apr 14 '14 at 8:28
Clive, can you have a time greater than PHP's max_execution_timeout? Is leaving it at 15 a best practice if you have the timeout set to 30 sec in php.ini? What if you have 3 queues provided by modules that take 15 sec each? – Bart Aug 8 '14 at 9:48

The answer is obvious if you look at the following two items in combination:

  • 'worker callback': The name of the function to call. It will be called with one argument, the item created via DrupalQueue::createItem().

  • 'time': (optional) How much time Drupal should spend on calling this worker in seconds. Defaults to 15. (my emphasis)

So the optional time value is the maximum time that will spent, during a cron run, to execute the callback worker callback function that you supply in your implementation of this hook.

share|improve this answer
OK - somebody seems to think this answer is wrong. Could someone (not necessarely the downvoter) please explain why it is wrong, given what the documentation says? – Free Radical Apr 14 '14 at 8:05
This definitely isn't wrong, can't think why it's been downvoted – Clive Apr 14 '14 at 8:39
I'm not the downvoter ;). Your answer is not wrong but did not answer my question though. And I'm the one that was confused. – Quentin Campbell Apr 14 '14 at 8:46

Queue items will be processed until the "time" value has expired. The processing may take longer than this, but no new items will be processed after this time has passed.

So, for example, if "time" is 15 and each queue item takes 14 seconds to process, the processing will deal with two items, taking 28 seconds in total. The second item is processed because the first item has finished before the time has expired.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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