Reputation: 1979
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?
Upvotes: 18
Views: 47395
Reputation: 3128
You can use :
To retry all of your failed jobs, execute the queue:retry command and pass all as the ID:
php artisan queue:retry all
Source : https://laravel.com/docs/9.x/queues#retrying-failed-jobs
Check the result via :
php artisan queue:failed
> No failed jobs!
Important Note : If you don't have workers, remember to run the queue as this command will only push these fail jobs back to the queue and WILL NOT execute them. (Which makes sense, if you think about it.)
Upvotes: 4
Reputation: 21
Try using the command below in your CLI : "php artisan queue:retry"
This command will push all failed queues back to the job table and rerun it again by typing; "php artisan queue:work"
Upvotes: 0
Reputation: 273
One way to do this via artisan is to specify a range. Even if not every ID in the range exists, artisan will still fire all of the failed jobs, skipping over the ones it can't find. For example, if you have a bunch of jobs sparsely populated between IDs 200 and 510 you can do:
php artisan queue:retry --range 200-510
Upvotes: 5
Reputation: 1300
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
Upvotes: 39
Reputation: 105
I've created a command to execute this operation: https://gist.github.com/vitorbari/0ed093cf336278311ec070ab22b3ec3d
Upvotes: 1
Reputation: 5008
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.
Upvotes: 11
Reputation: 2487
I couldn't find an answer to this (I don't think laravel provides this by default) so I wrote a bash script to retry all the jobs I needed:
#!/bin/bash
for i in {53..800}
do
php artisan queue:retry $i
done
Upvotes: 7