Quoting https://laravel.com/docs/5.1/scheduling#preventing-task-overlaps ,
$schedule->command('emails:send')->withoutOverlapping();In this example, the
emails:sendArtisan command will be run every minute if it is not already running.
What if I wanted the task to run every five minutes instead? Could I do this?:
$schedule->command('emails:send')->everyFiveMinutes()->withoutOverlapping();
Yes you can do this. command returns an instance of Event the underlying code for Event has a fluent interface which allows you to chain these together in this way.
You can see this for yourself if you look at the withoutOverlapping method.
/**
* 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());
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With