Created
July 24, 2019 12:12
-
-
Save fredsted/846410708abd55459664e11136e7f297 to your computer and use it in GitHub Desktop.
Retry all failed laravel jobs without causing a memory leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pdo = new PDO( | |
sprintf( | |
'mysql:host=%s;dbname=%s', | |
getenv('DB_HOST'), | |
getenv('DB_DATABASE') | |
), | |
getenv('DB_USERNAME'), | |
getenv('DB_PASSWORD') | |
); | |
$rows = $pdo->query('select id from failed_jobs')->fetchAll(); | |
$count = count($rows); | |
echo sprintf("%d failed jobs found\n", $count); | |
foreach ($rows as $index => $row) { | |
echo sprintf( | |
"%08d/%08d: %s\n", | |
$index, | |
$count, | |
exec(sprintf('php artisan queue:retry %d', $row['id'])) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment