【发布时间】:2018-02-24 16:56:47
【问题描述】:
如果失败,我想在 laravel 调度程序中重新运行作业,假设如下:
Kernal.php
protected function schedule(Schedule $schedule)
{
$this->generateData($schedule);
}
protected function generateData($schedule){
$schedule->command('My Command')
->monthly()
->after(function ($schedule){
$command = DB::table('commands')
->where("name","My Command")
->orderBy('id', 'desc')
->first();
if(!$command->succeeded){
echo "task not finished";
$this->generateData($schedule);
}
else{
echo "task finished";
return;
}
});
}
这个命令有时会失败,在函数之后我检查命令是否失败,然后我尝试再次重新执行它,但这不起作用,我收到以下错误:
[ErrorException]
App\Console\Kernel::App\Console{closure}() 缺少参数 1
有什么建议吗?
【问题讨论】:
标签: php laravel laravel-5 laravel-scheduler