$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 .
[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
The scheduler allows you to fluently and expressively define your command schedule within your Laravel application itself. When using the scheduler, only a single cron entry is needed on your server. Your task schedule is defined in the app/Console/Kernel.php file's schedule method.
The WithoutOverlapping middleware provided by Laravel can be used to prevent overlapping of jobs based on an arbitrary key. For instance, in our case, it would be the user's id for which we are updating the wallet's balance.
Laravel Cron Job SchedulingLaravel's 'Command Scheduler' allows you to easily define the schedule of the commands within Laravel itself. When using the scheduler, only one Cron entry is needed on the server. Your task schedule is defined in the app/Console/Kernel. php file's schedule method.
Just name your task with a call to name() and chain the methods that define when your task should be run.
$schedule->call(function () {
//Some Code
})->everyFiveMinutes()
->name('some_name')
->withoutOverlapping();
For anonymous functions the name is required to prevent overlapping.
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