Command Commands in the Laravel Artisan Scheduler?

Suppose I have three commands that I want to schedule: 'commandA', 'commandB' and 'commandC'

But I do not want to run "commandB" until "commandA" is complete, and I do not want to run "commandC" until "commandB" is complete.

I know that every schedule can be scheduled every five minutes:

$schedule->command('commandA')->everyFiveMinutes();
$schedule->command('commandB')->everyFiveMinutes();
$schedule->command('commandC')->everyFiveMinutes();

But is it possible to connect them one by one?

+4
source share
1 answer

Use then (Closure $ callback) for chaining commands:

$schedule->command('commandA')->everyFiveMinutes()->then(function() {
    $this->call('commandB');
    $this->call('commandC');
});
+13
source

Source: https://habr.com/ru/post/1584282/


All Articles