Reputation: 1376
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!
P.S. I use Laravel 5.2, in case that matters.
Upvotes: 3
Views: 7245
Reputation: 1619
You can use this code for the second part of the question
->weekdays()->at('time you want')
Based on the Laravel documentation.
Upvotes: 11
Reputation: 163778
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);
}
Upvotes: 6