I undestand that you can create hourly tasks on Laravel by using:
$schedule->command('catalog:update')->hourly();
however is there a way to do for example every 2 hours or 5 hours? I couldn't find it on documentation or here.
I undestand that you can create hourly tasks on Laravel by using:
$schedule->command('catalog:update')->hourly();
however is there a way to do for example every 2 hours or 5 hours? I couldn't find it on documentation or here.
You've tagged your question as Laravel 4, but I don't think the scheduler was introduced until Laravel 5...
Anyway, based on the code snippet you've posted, you could use the cron
method.
$schedule->command('catalog:update')->cron('0 */2 * * *'); // every 2 hours
$schedule->command('catalog:update')->cron('0 */5 * * *'); // every 5 hours
See the docs for other options. https://laravel.com/docs/5.4/scheduling#defining-schedules
From Laravel 7 By Defalut you can give like this
$schedule->command('catalog:update')->everyTwoHours();
$schedule->command('catalog:update')->everyFiveHours();
Laravel scheduling hours cron-command can only run a task every 2 hours, 3 hours, 4 hours and 6 hours.There is no everyFiveHours() command you will have to use the cron
command for 5 hours, cron('0 */5 * * *')
.
Below commands are supported:
->everyTwoHours();
->everyThreeHours();
->everyFourHours();
->everySixHours();
© 2022 - 2024 — McMap. All rights reserved.
* * * * * php /path/to//artisan schedule:run >> /dev/null 2>&1
again? – Bloodmobile