Laravel scheduler run twiceDaily at specific hours

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

How can I run Laravel scheduler twice daily at specific hours? Let's say I want my command to run every day at 9am and 5pm

There is an option to use twiceDaily, but I'm not sure how to specify hours

回答1:

You can use manual cron expression:

$schedule->command('foo')->cron('0 9,17 * * *'); 

Read more: http://laravel.com/docs/5.0/artisan#scheduling-artisan-commands


If you're not familiar with cron expressions, here's the nice GUI: http://cron.nmonitoring.com/cron-generator.html



回答2:

If you want to use the Schedulable method then it would look like this:

return $scheduler->twiceDaily(9, 17);



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!