I have a Laravel 5 task which I am scheduling to run between a specified time range every day:
$schedule->call(function () {
// task omitted
})->daily()->timezone('Europe/London')->between('14:00', '15:00');
This does not work, however if I change it to run every minute using everyMinute();
then it does run successfully:
$schedule->call(function () {
// task omitted
})->everyMinute();
My CRON on the server is set to run every half an hour as it's a shared hosting so it can't run for less than half an hour:
0,30 * * * * /usr/local/bin/php -q /home/username/public_html/bookings/artisan schedule:run >> /dev/null 2>&1
Anyone know why the first cron job: daily()->timezone('Europe/London')->between('14:00', '15:00');
is not running?
You have a conflicting rule.
https://laravel.com/docs/5.5/scheduling
daily() sets the task to run daily at midnight. between() limits the task to only run between certain hours (basically a secondary condition).
So your between rule is going to make it so it never runs since it will be only be run at midnight then it will fail the between condition.
Use dailyAt('14:00')
instead of daily()->between()