1

I'm currently working on a custom CakePhp Shell. A cronjob starts the Shell. The Shell executes a worker (task). Simple and easy.

The shell starts a task worker:

$this->WorkerTask->execute();

How to create 10 WorkerTasks in one movement?

Is this legal:

for($i=0; $i<10; $i++){
    $this->WorkerTask->execute();
}

or:

for($i=0; $i<10; $i++){
    $this->WorkerTask = new WorkerTask();
    $this->WorkerTask->execute();
}
erwineberhard
  • 309
  • 4
  • 17
  • 2
    What cake version? And do you want them to run in parallel? Because by default you get always 1 instance of task, besides it will not run the next `execute()` before the previous has finished. If yes, this [question](http://stackoverflow.com/questions/909791/asynchronous-processing-or-message-queues-in-php-cakephp) might give you some more info. If not, you can simply place the the loop inside `WorkerTask::execute()` – lp1051 Feb 10 '14 at 11:17
  • Thank you! Yes, i'm working with Beanstalk. That's the way to go. Next step is a cronjob. Before executing the task the shell will check the count of workers on a certain tube. Is the max count of workers reached, the shell wil die. Thanks for helping!! – erwineberhard Feb 10 '14 at 14:54

0 Answers0