Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 - retry all failed jobs

Tags:

php

queue

laravel

In the laravel 4.2 docs it is said that if I want to retry failed job from the failed jobs table I should do:

php artisan queue:retry 5

where 5 is the job id.

How can I retry all failed jobs at once?

like image 796
Alexander Nikolov Avatar asked Jun 11 '15 10:06

Alexander Nikolov


People also ask

How do I retry failed jobs in laravel?

You can retry all failed Jobs by running: php artisan queue:retry all . The question is for Laravel 4, but yes.

What is queue job in laravel?

Laravel queues provide a unified queueing API across a variety of different queue backends, such as Amazon SQS, Redis, or even a relational database. Laravel's queue configuration options are stored in your application's config/queue.php configuration file.


2 Answers

You can retry all failed Jobs by running: php artisan queue:retry all.

here is official doc: https://laravel.com/docs/7.x/queues#retrying-failed-jobs

like image 127
Riajul Avatar answered Oct 04 '22 14:10

Riajul


Laravel docs says:

To retry all of your failed jobs, use queue:retry with all as the ID:

php artisan queue:retry all

However this doesn't work for me. I get "No failed job matches the given ID.". What I did was I ran a command allowing me to execute php:

php artisan tinker

And wrote this:

for ($i = 100; $i <= 150; $i ++) Artisan::call('queue:retry', ['id' => $i]);

Here 100 and 150 are your failed job IDs range. I used to retreive them from DB dynamically but that won't work if you use another queue driver.

What this does is it loops through the IDs in the range you specified and calls a "php artisan queue:retry XXX" command for every single one of them.

like image 27
MaGnetas Avatar answered Oct 04 '22 16:10

MaGnetas