Ad

Laravel Schedule WithoutOverlapping() Is Not Working With RunInBackground()

- 1 answer

I'm trying to setup schedule for my commands in /app/Console/Kernel.php and found out that withoutOverlapping() doesnt work with runInBackground()

This works without overlaps:

$schedule
    ->command('test:update')
    ->withoutOverlapping();

This overlaps tasks:

$schedule
    ->command('test:update')
    ->withoutOverlapping()
    ->runInBackground();
Ad

Answer

In the first case, it was working without overlaps because command was running in the foreground and scheduler was busy processing this command thus didn't run new one until current command finished. withoutOverlapping() did not impact anything here.

So the problem was that the mutex is not being created withwithoutOverlapping(). Laravel scheduler is using cache for mutex. Switching cache driver to redis helped fix this issue, now withoutOverlapping() works as it should.

Ad
source: stackoverflow.com
Ad