I'm trying to run a command the last day of the month at 06:00, I tried doing this
$schedule->command('crawl')->when(function () {
return \Carbon\Carbon::now()->endOfMonth()->isToday();
})->at('06:00');
It does run on the last day, but the "at" does not work. Any idea how I can get it to work?
I'd simply use the monthlyOn()
schedule method, because it gives you the opportunity to point at a given day of the month and a daytime to execute the command. Using php's date()
function to retrieve the count of days in a month, this becomes an enjoyable task:
->monthlyOn(date('t'), '6:00');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With