在本月的最后一个星期一运行cron-Laravel
我只想在本月的最后一个星期一使用Laravel的cron API运行cron。我已经检查过了: 我没有得到任何解决方案 我最多可以:在本月的最后一个星期一运行cron-Laravel,laravel,laravel-5,cron,laravel-5.3,Laravel,Laravel 5,Cron,Laravel 5.3,我只想在本月的最后一个星期一使用Laravel的cron API运行cron。我已经检查过了: 我没有得到任何解决方案 我最多可以: $schedule->command(Commands\PerformerReminder::class)->monthly()->mondays(); 但我认为它将在每月的每个周一运行cron,而不仅仅是在上周一 如果使用Laravel的cron API无法做到这一点,那么我可以使用常规的cron选项 我想会是这样的: $schedule-
$schedule->command(Commands\PerformerReminder::class)->monthly()->mondays();
但我认为它将在每月的每个周一运行cron,而不仅仅是在上周一
如果使用Laravel的cron API无法做到这一点,那么我可以使用常规的cron选项
我想会是这样的:
$schedule->command(Commands\PerformerReminder::class)->cron('* * * * *);
我不知道cron()函数中的值是什么
任何帮助都将受到感谢
谢谢
帕斯·沃拉怎么样
use Carbon;
$schedule->command(Commands\PerformerReminder::class)->mondays()->when(function(){
// return true if this monday is last monday of this month
return (Carbon::now()->isSameDay($now->lastOfMonth(Carbon::MONDAY)));
});
怎么样
use Carbon;
$schedule->command(Commands\PerformerReminder::class)->mondays()->when(function(){
// return true if this monday is last monday of this month
return (Carbon::now()->isSameDay($now->lastOfMonth(Carbon::MONDAY)));
});
我在工作中发现: App/Console/Kernal.php:
protected function schedule(Schedule $schedule)
{
$schedule->command(Commands\PerformerReminder::class)->when(function() {
return (new Carbon('last monday of this month'))->isToday();
});
}
我在工作中发现: App/Console/Kernal.php:
protected function schedule(Schedule $schedule)
{
$schedule->command(Commands\PerformerReminder::class)->when(function() {
return (new Carbon('last monday of this month'))->isToday();
});
}
您是否尝试过
->何时(关闭)代码>?哦,是的。我完全忽略了这个选择。让我试试那个。谢谢。你试过->when(close)代码>?哦,是的。我完全忽略了这个选择。让我试试那个。谢谢。return$lastmaniday->isToday()代码>足够了返回新的碳(“本月的最后一个星期一”)->isToday()
甚至更短:)返回$lastmaniday->isToday()代码>足够了返回新的碳(“本月的最后一个星期一”)->isToday()代码>甚至更短:)