Laravel Scheduler withoutOverlapping()
· 1 min read
If a scheduled task can run longer than its interval, the scheduler will happily
start a second copy. withoutOverlapping() prevents that with a cache lock:
$schedule->command('reports:sync')
->everyMinute()
->withoutOverlapping(10);
The argument is the lock’s expiry in minutes — not a timeout for the task.
Without it the default is 24 hours, so a process killed with SIGKILL leaves a
lock behind and the job silently stops running for a day. Always pass a value
slightly above the task’s realistic worst case.
Worth pairing with onOneServer() if you run the scheduler on more than one
machine — withoutOverlapping() alone doesn’t coordinate across hosts unless
the cache driver is shared.