0

I am trying to implement a Queue for my cron job, but some how it is not working. Following is the code snippet I have tried, but it is not working.

function hook_cron() {
watchdog('notice', 'Cron is executed');
$queue = DrupalQueue::get('update_item');
  for($i=0;$i<=10;$i++){
    $queue->createItem($i);
  }
}
function hook_cron_queue_info() {
  watchdog('notice', 'called queue info');
  $queues['update_item'] = array(
    'worker callback' => '_my_queue_callback',
    'time' => 15,
  );
  return $queues;
}
function _my_queue_callback($data){
   watchdog('notice', "Queue call back $data");
}

Following output I am expecting in logs "Cron is executed" "Called queue info" and "Queue call back 1"..."Queue call back 10"

But I am only getting

"Cron is executed"

I am runing the cron using elysia_cron interface (in my linux box cron job is not added in crontab). What might be the reason I am not getting "Called queue info" and "Queue call back 1"..."Queue call back 10" in my logs.

4
  • Why is not working? No watchdog messages? Any warning or error messages? Are you sure cron is called? Have you clreaded your caches?
    – sanzante
    Sep 12, 2014 at 12:17
  • @tunic cron is running . Other lines are not executing . Sep 12, 2014 at 12:21
  • Keep in mind that Elysia Cron enusre the time between cron executions, so if you have configured a cron function to execute every day and you have execute it today Elysia won't exceute it until next day.
    – sanzante
    Sep 12, 2014 at 12:47
  • Thanks @tunic for your great help, after adding it to the cron.php to the queue started working . I was trying to run the cron using elysia cron that was the problem Sep 17, 2014 at 6:47

0

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.

Browse other questions tagged or ask your own question.