I need schedule my task every hour on 08:00, 12:00, 16:00 and 20:00, 22:00. How I can do it?
Now I set:
$schedule->command(vkliketime::class)
->hourly()
->between('8:00', '22:00');
But this is not correct, I need run task only in times 08:00, 12:00, 16:00 and 20:00, 22:00
I’d create a foreach loop for this, like:
$hours=[“08:00”, “12:00”, “16:00”, “20:00”, “22:00”];
foreach($hours as $hour) {
$schedule->command(vkliketime::class)
->dailyAt($hour);
}
There's also a less readable option using the cron()
function.
$schedule
->command('vkliketime::class')
->cron('0 0 8,12,16,20,22 ? * * *');
But from what I can gather a simple loop like Zoli provided would be preferable.