Skip to content
Advertisement

How to get all pending jobs in laravel queue on redis?

The queue:listen was not run on a server, so some jobs were pushed (using Redis driver) but never run.

How could I count (or get all) these jobs? I did not find any artisan command to get this information.

Advertisement

Answer

If someone is still looking for an answer, here is the way I did it:

$connection = null;
$default = 'default';

// For the delayed jobs
var_dump(
    Queue::getRedis()
        ->connection($connection)
        ->zrange('queues:'.$default.':delayed', 0, -1)
);
    
// For the reserved jobs
var_dump(
    Queue::getRedis()
        ->connection($connection)
        ->zrange('queues:'.$default.':reserved', 0, -1)
);

$connection is the Redis’ connection name which is null by default, and the $default is the name of the queue which is default by default.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement