Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Task Scheduling Every X Hours

Tags:

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.

like image 222
senty Avatar asked Mar 15 '17 02:03

senty


1 Answers

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

like image 71
fubar Avatar answered Oct 29 '22 21:10

fubar