withoutOverlapping() 在 Laravel Schedule 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34555467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
withoutOverlapping() is not working in Laravel Schedule
提问by Awais Mushtaq
$schedule->call(function ()
{
error_log("Line Schedule 1:Start");
//Send Email
error_log("Line Schedule 1:End");
})->everyFiveMinutes()->name('event_name:1')->withoutOverlapping();
$schedule->call(function ()
{
error_log("Line Schedule 2:Start");
//Send Email
error_log("Line Schedule 2:End");
})->everyFiveMinutes()->name('event_name:2')->withoutOverlapping();
$schedule->call(function ()
{
error_log("Line Schedule 3:Start");
//Send Email
error_log("Line Schedule 3:End");
})->everyFiveMinutes()->name('event_name:3')->withoutOverlapping();
i run these schulders using command php artisan schedule:run and i am running many instances in parallel. and my logs file says that schulder 2 is starting second time even its previous instance has not completed it yet .
我使用命令 php artisan schedule:run 运行这些 schulders,并且我正在并行运行许多实例。我的日志文件说 schulder 2 正在第二次启动,即使它的前一个实例还没有完成它。
[01-Jan-2016 11:30:08 UTC] Line Schedule 1:Start
[01-Jan-2016 11:30:11 UTC] Line Schedule 2:Start
[01-Jan-2016 11:30:13 UTC] Line Schedule 3:Start
[01-Jan-2016 11:30:15 UTC] Line Schedule 1:End
[01-Jan-2016 11:30:15 UTC] Line Schedule 2:Start
[01-Jan-2016 11:30:17 UTC] Line Schedule 2:End
[01-Jan-2016 11:30:17 UTC] Line Schedule 3:Start
[01-Jan-2016 11:30:19 UTC] Line Schedule 3:End
[01-Jan-2016 11:30:21 UTC] Line Schedule 2:End
[01-Jan-2016 11:30:21 UTC] Line Schedule 3:Start
[01-Jan-2016 11:30:22 UTC] Line Schedule 3:End
[01-Jan-2016 11:30:25 UTC] Line Schedule 3:End
回答by jedrzej.kurylo
Just name your task with a call to name()and chain the methods that define when your task should be run.
只需通过调用name()命名您的任务,并链接定义您的任务何时运行的方法。
$schedule->call(function () {
//Some Code
})->everyFiveMinutes()
->name('some_name')
->withoutOverlapping();
For anonymous functions the name is required to prevent overlapping.
对于匿名函数,需要名称以防止重叠。