0

调度程序在奇怪的时间运行,我配置了一个每分钟运行的任务并且在本地运行正常,但是在 prod 服务器中运行有时会重复。

这是我的 Kernel.php 代码

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    protected $commands = [];


    protected function schedule(Schedule $schedule)
    {

        $schedule->call(function () {
            return true;
        })->everyMinute()->emailOutputTo('...')->thenPing('...');

    }

    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }


}

我从产品服务器获得的执行输出:

19.06
19.07
19.08
19.09
19.10
19.11
19.12
19.13
19.16
19.16
19.16
19.17
19.18
19.21
19.21
19.21
19.22
19.23
19.25
19.25
19.26

有任何想法吗?

4

1 回答 1

1

查看输出,它似乎每分钟都在运行,但有时执行任务需要更多时间,并且可能在完成工作后节省时间,例如:

19.12 -> was started at 19:12 and finished at 19:12
19.13 -> was started at 19:13 and finished at 19:13
19.16 -> was started at 19:14 and finished at 19:16
19.16 -> was started at 19:15 and finished at 19:16
19.16 -> was started at 19:16 and finished at 19:16
19.17 -> was started at 19:17 and finished at 19:17
于 2018-09-28T18:07:36.467 回答