问题描述
我尝试在Laravel 5上运行计划.运行此程序可以正常工作:
I try to run schedule on Laravel 5. Its work fine when I run this:
$schedule->call(function() {
// do something here..
})->everyMinute();
但是当我添加 withoutOverlapping()
时,调度程序将永远不会运行任务:
But when I add withoutOverlapping()
, the scheduler never run the task:
$schedule->call(function () {
// do something here..
})->everyMinute()->name('job_name')->withoutOverlapping();
*这些计划代码写在/app/Console/Kernel.php
*these schedule code is written at /app/Console/Kernel.php
推荐答案
在使用-> withoutOverlapping()
时删除-> everyMinute()
每分钟但没有重叠.
Delete ->everyMinute()
when using ->withoutOverlapping()
it will still run every minute but without overlapping.
从Laravel v.5.5开始,您可以指定在无重叠"锁定失效之前必须经过的分钟数.
Since Laravel v. 5.5+ you can specify on how many minutes must pass before the "without overlapping" lock expires.
例如-> withoutOverlapping(10)
可用于在10分钟过去后解锁重叠".
eg. ->withoutOverlapping(10)
can be used to unlock the "overlapping" when 10 minutes will pass.
这篇关于Laravel 5-没有重叠的任务计划不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!