Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 每分钟都无缘无故执行Laravel任务调度_Php_Laravel_Cron - Fatal编程技术网

Php 每分钟都无缘无故执行Laravel任务调度

Php 每分钟都无缘无故执行Laravel任务调度,php,laravel,cron,Php,Laravel,Cron,我设置了一个命令,该命令必须在每月的最后一天运行一次。我就是这样做的: $schedule->command('report:send')->when(function () { return Carbon::now()->endOfMonth()->isToday(); }); 今天是一个月的最后一天,所以它工作得很好。但问题是这个命令每分钟都在执行。因此,每分钟我都会收到收件箱中的一封电子邮件:/ 这是否可能是因为我使用了->everyMinute()测试时

我设置了一个命令,该命令必须在每月的最后一天运行一次。我就是这样做的:

$schedule->command('report:send')->when(function () {
    return Carbon::now()->endOfMonth()->isToday();
});
今天是一个月的最后一天,所以它工作得很好。但问题是这个命令每分钟都在执行。因此,每分钟我都会收到收件箱中的一封电子邮件:/


这是否可能是因为我使用了
->everyMinute()测试时,必须刷新设置或执行其他操作?

每次启动cron时都会测试该命令。我相信您的cron每分钟都会执行一次,因为今天的命令return true,它每分钟都会执行一次

您可以做的是:

$schedule->command('report:send')->daily()->when(function () {
    return Carbon::now()->endOfMonth()->isToday();
});


我想你可以试试这个:

$schedule->command('report:send')->monthly()->when(function () {
    return Carbon::now()->endOfMonth()->isToday();
});

希望这对您有用

您是否尝试过进一步限制回调,例如仅在11:22时执行?@sisve不,我没有,我怎么能这样做?嗯,目前是我的本地时间08:50,我已将其设置为
->dailyAt('08:48'))
但什么也没发生?可能是我的服务器时间有问题,我会检查我的服务器时间并相应地更改
$schedule->command('report:send')->monthly()->when(function () {
    return Carbon::now()->endOfMonth()->isToday();
});