I am writing Laravel scheduler task and want to run it once a day every weekday (From Monday to Friday).
I see that Task Scheduler has ->weekdays()
option, that presumably does precisely what I want. But I wasn't able to find a confirmation or description of this option that says it will run from Monday to Friday and not, say, from Monday to Saturday.
Also I would like to run the task at specific time. I see there is a ->dailyAt('13:00');
method. I'd like to know the best solution to run task at weekdaysAt.
Thanks in advance!
PS I use Laravel 5.2, in case that matters.
You can use this code for the second part of the question
->weekdays()->at('time you want')
Based on the Laravel documentation .
I guess this is a confirmation, the source code of the weekdays()
method:
public function weekdays()
{
return $this->spliceIntoPosition(5, '1-5');
}
You can find it here: \\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Scheduling\\Event.php
Right after weekdays()
you will see mondays()
method, which shows that Laravel counts mondays as "day 1":
public function mondays()
{
return $this->days(1);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.