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

jordan.dobrev.88@gmail.com's avatar

Envoyer deploy and endless scheduled jobs

Hi guys,

I have an endless loop that is part of my scheduled tasks. Each iteration of the work that I am doing takes around 1s:

//Kernel.php
$schedule->command("endlessjob")->withoutOverlapping();
//command handle body

while(true) {
    doJob();
    sleep(1);
}

It all works fine but when I want to deploy a new release I want to gracefully stop the job before the Laravel scheduler starts it again.

Sth like this:

//command handle body

while(true) {
    if(detectIfNewCodeWasDeployed()) {
        return;
    }
    doJob();
    sleep(1);
}

Any ideas how I can solve it without making it too complex? Thx

0 likes
0 replies

Please or to participate in this conversation.