运行每五分钟一个任务不重叠?

running a task every five minutes without overlapping?

引用 https://laravel.com/docs/5.1/scheduling#preventing-task-overlaps ,

$schedule->command('emails:send')->withoutOverlapping();

In this example, the emails:send Artisan command will be run every minute if it is not already running.

如果我希望任务每五分钟 运行 怎么办?我可以这样做吗?:

$schedule->command('emails:send')->everyFiveMinutes()->withoutOverlapping();

是的,你可以做到。 command returns Event 的实例 Event 的底层代码有一个流畅的接口,允许您以这种方式将它们链接在一起。

如果您查看 withoutOverlapping 方法,您可以自己看到这一点。

/**
 * Do not allow the event to overlap each other.
 *
 * @return $this
 */
public function withoutOverlapping()
{
    $this->withoutOverlapping = true;
    return $this->skip(function () {
        return file_exists($this->mutexPath());
    });
}