When using the Laravel Task Scheduler I'm facing a problem when using the 'between' parameter.
I've got the following
$schedule->command('route:call import/start')
->everyFifteenMinutes()
->between('22:00', '03:00')
->withoutOverlapping()
->appendOutputTo(storage_path() . '/logs/import/'.date('Y/m/d').'/start_ ' . date('H').'.txt');
So I expect to run it every 15 minutes between 22:00 and 03:00. However, it runs every 15 minutes EXCEPT when its between 22:00 and 03:00.
Every other scheduled task like 'dailyAt('22:00')' is working like expected.
We call Carbon::between which swaps the arguments around. Your code becomes 03:00 - 22:00 because of this.
A workaround would be to add two between intervals, 22:00-23:59 and 00:00-03:00.
I had the same problem before, and I ended up using the same workaround @sisve proposed.
That may not be ideal, but I've seen worse.
Why is this closed? Can see it as a common use case and a workaround isn't a fix.
EDIT: a better workaround is to just append +1 day to the end of the end time. Which I think is probably a good enough workaround to not need any sort of fix.
Most helpful comment
Why is this closed? Can see it as a common use case and a workaround isn't a fix.
EDIT: a better workaround is to just append
+1 dayto the end of the end time. Which I think is probably a good enough workaround to not need any sort of fix.