Reputation: 809
I want do this job oly on this days can I use at() with when() ????
$schedule->command('mycommand')->when(function () {
$day = Carbon::today()->day;
if($day == 3 || $day == 5 || $day == 7 || $day == 22) {
return true;
} else {
return false;
}
})->at('17:00');
Upvotes: 0
Views: 788
Reputation: 10714
You can use this way :
$schedule->command('mycommand')->monthlyOn(3, '17:00');
$schedule->command('mycommand')->monthlyOn(5, '17:00');
$schedule->command('mycommand')->monthlyOn(7, '17:00');
$schedule->command('mycommand')->monthlyOn(22, '17:00');
Or, simpler way, using cron :
$schedule->command('mycommand')->cron('0 17 3,5,7,22 * *');
Upvotes: 4
Reputation: 11034
You can duplicate multiple monthly runs on specific days
$schedule->command('mycommand')->monthlyOn(3, '17:00');
$schedule->command('mycommand')->monthlyOn(5, '17:00');
$schedule->command('mycommand')->monthlyOn(7, '17:00');
$schedule->command('mycommand')->monthlyOn(22, '17:00');
Hope this helps
Upvotes: 2