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

Čamo's avatar

Is there a way to properly delete a Laravel job from the queue?

I have a job which is set up as ShouldBeUnique and WithoutOverlaping and $backoff array of delays. So there could be this job in the queue with some long delay after fail and I need to run this job imediatelly by calling dispatch() manually from the code. But I can not because the job is already in the queue but because of delay it will not run imediatelly. I tried to find out how to do it, but it seems Laravel does not have something like forget() method for the jobs in the queue. Is there a way to do it? Gemini said I need to remove ShouldBeUnique and dontRelease(). But I dont like to remove ShouldBeUnique. I would like to clear the job from the queue. Thanks for help.

0 likes
5 replies
Glukinho's avatar

If your queue engine is database, you can remove jobs from queue manually:

DB::table('jobs')->where('payload->displayName', 'App\\Jobs\\YourJob')->delete();

After that, you can dispatch new job.

Not the nicest solution, but it may work.

Čamo's avatar

@Glukinho Yes I know about this solution but want to know if there is something like best practise to do it.

Glukinho's avatar

@Čamo maybe you put your job to separate queue and after that you can clear this queue with a command:

php artisan queue:clear --queue=custom-queue

This is a native way, see here: https://laravel.com/docs/12.x/queues#clearing-jobs-from-queues

Don't forget to tune your queue worker to handle this new custom queue.

PS I bet this command executes nearly the same SQL DELETE query :)

1 like
Čamo's avatar

@Glukinho Thanks its ok, I removed the ShouldBeQunique and dontRelease(). The handle will handle it.

Please or to participate in this conversation.