Laravel scheduler run twiceDaily at specific hours

2019-04-28 09:59发布

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

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-28 10:17

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

查看更多
Lonely孤独者°
3楼-- · 2019-04-28 10:28

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

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

查看更多
登录 后发表回答