首页 > 解决方案 > 我的 Laravel Schedule withoutOverlapping() 不适用于 runInBackground()

问题描述

我看到其他人在这里遇到了同样的问题,但是当我尝试他们的解决方案时,它似乎仍然不起作用。

我正在运行 Laravel 5.7

我已将 redis 设置为我的缓存:

CACHE_DRIVER=redis

但是在 database.php 中我需要编辑什么吗?

    'redis' => [

    'client' => 'predis',

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => 0,
    ],

我已经做好了:

composer install predis/predis

我可以确认 redis 正在工作:

KEYS *
  1) "laravel:framework/schedule-3032780d7b5657bd5e6ba0fef1359f330895c3da"

我有 15 个任务在不同时间运行,但似乎第一个任务运行,但之后的其他任务没有。

$schedule->command( 'do:task one' )->cron( '1/3 * * * *' )->withoutOverlapping()->runInBackground();
$schedule->command( 'do:task two' )->cron( '1/5 * * * *' )->withoutOverlapping()->runInBackground();
$schedule->command( 'do:task three' )->cron( '1/15 * * * *' )->withoutOverlapping()->runInBackground();

有没有其他人遇到过这个?

谢谢

标签: laravel-5.7

解决方案


推荐阅读