peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
811 stars 144 forks source link

Linux Run Background Parallel #109

Open elvispdosreis opened 4 years ago

elvispdosreis commented 4 years ago

I noticed that my scheduled processes run in sequence that were scheduled, and it is possible that these processes run in parallel.

in a simplified way and the way I use it, with an array containing all my tasks

$task = new Task('0 0,12 * * *', true, 'price', 'Price');
array_push($tasks, $task);

foreach ($tasks as  $task){
    /** @var $task Task */
    $scheduler->call(function (Task $task) {
        ...
    }, [$task], "{$task->getSlug()}")->at($task->getExpression())->before(function () {
        ...
    })->then(function ($output) {
        ...
    }, $task->isBackground())->onlyOne('/tmp/');
}