本文介绍了Laravel Artisan Scheduler中的链命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我要调度三个命令:'commandA','commandB'和'commandC'
Suppose I have three commands I want to schedule:'commandA', 'commandB', and 'commandC'
但是我不想在'commandA'完成之前运行'commandB',并且我不想在'commandB'完成之前运行'commandC'.
But I don't want to run 'commandB' until 'commandA' is complete and I don't want to run 'commandC' until 'commandB' is complete.
我知道我可以安排每五分钟运行一次
I know I can schedule each to run every five minutes:
$schedule->command('commandA')->everyFiveMinutes();
$schedule->command('commandB')->everyFiveMinutes();
$schedule->command('commandC')->everyFiveMinutes();
但是可以将它们一个接一个地链接吗?
But is it possible to chain them one after the other?
推荐答案
使用然后(关闭$ callback)链接命令:
$schedule->command('commandA')->everyFiveMinutes()->then(function() {
$this->call('commandB');
$this->call('commandC');
});
这篇关于Laravel Artisan Scheduler中的链命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!