Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

omar_8's avatar

task schedule (withoutOverlapping) not working as expected

i have multi task schedule each of them need long time to be finished so i'have used (withoutOverlapping) method but it's blocking the full task schedule not just the first one for example:

//need about 20 minutes

 $schedule->command('some command')->withoutOverlapping();

//need about 15 minutes

  $schedule->command('some other command')->withoutOverlapping();

the first one is blocking the second until it's done execution,

is there any way to block the current task only so the next cron can skip the first task and start the next task.

i'know the first cron will continue the execution after the first one is done but the data will take soo much time to be processed since i'have about 6 task each of them needs 20 to 30 minute of execution time.

any idea!!

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

The withoutOverlapping feature uses a simple lock file to say that the scheduler is running... therefore it does not care that your commands are different.

The function uses a mutex function, this is where the file is stored;

    /**
     * Get the mutex path for the scheduled command.
     *
     * @return string
     */
    protected function mutexPath()
    {
        return storage_path('framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command));
    }

and uses the name of the command. You might be able to vary the name of the lock file by calling the scheduler with a different command line parameter

You could write your own mutex that is specific to the command?

CoedNaked's avatar

Use ->runInBackground() . this will prevent the "rest" of your scheduled tasks from being blocked

$schedule->command('some command')->hourly()->runInBackground();
$schedule->command('some command 2')->hourly()->runInBackground();

Please or to participate in this conversation.