Laravel Scheduler产品服务器中的奇怪行为

时间:2018-09-28 18:03:22

标签: laravel laravel-5 artisan production laravel-scheduler

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

这是我的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

有什么想法吗?

1 个答案:

答案 0 :(得分: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