Skip to content

Queue Commands Reference

Complete reference for all queue-related Artisan commands in the Volare application.

Dispatch a test job to verify queue functionality.

Terminal window
./vendor/bin/sail artisan queue:test

What it does:

  • Dispatches a TestQueueJob with a test message
  • Confirms job was queued successfully
  • Provides next steps for monitoring

Display current queue status and pending jobs.

Terminal window
./vendor/bin/sail artisan queue:monitor

Example Output:

Queue Status:
Pending jobs: 5
Failed jobs: 0

Pro tip: Use with watch for live monitoring:

Terminal window
watch -n 2 './vendor/bin/sail artisan queue:monitor'

Start processing jobs on the queue.

Terminal window
./vendor/bin/sail artisan queue:work [connection] [options]

Important Options:

OptionDescription
--queue=Queues to process (comma-separated, priority order)
--onceProcess single job then exit
--stop-when-emptyStop when queue is empty
--sleep=Seconds to sleep when no jobs available (default: 3)
--tries=Number of times to attempt a job (default: 1)
--timeout=Maximum seconds a job should run (default: 60)
--max-time=Maximum seconds worker should run
--max-jobs=Maximum jobs to process before stopping
--memory=Memory limit in MB (default: 128)

Examples:

Terminal window
# Default queue worker (used in docker-compose.yml)
./vendor/bin/sail artisan queue:work --sleep=3 --tries=3 --max-time=3600
# Process specific queue with priority
./vendor/bin/sail artisan queue:work --queue=high-priority,default
# Process one job and exit
./vendor/bin/sail artisan queue:work --once

Listen to a queue and process jobs (with code reload).

Terminal window
./vendor/bin/sail artisan queue:listen [connection] [options]

Difference from queue:work:

  • Restarts framework on each job (slower but picks up code changes)
  • No need to manually restart after code changes
  • Not recommended for production

Signal all queue workers to restart after current job.

Terminal window
./vendor/bin/sail artisan queue:restart

When to use:

  • After deploying code changes
  • After config changes
  • After dependency updates

Retry failed jobs.

Terminal window
./vendor/bin/sail artisan queue:retry [id]

Examples:

Terminal window
# Retry all failed jobs
./vendor/bin/sail artisan queue:retry all
# Retry specific failed job
./vendor/bin/sail artisan queue:retry 9e3e9e3e-9e3e-9e3e-9e3e-9e3e9e3e9e3e
# Retry jobs from specific queue
./vendor/bin/sail artisan queue:retry all --queue=payments

Delete a failed job.

Terminal window
./vendor/bin/sail artisan queue:forget [id]

Delete all failed jobs.

Terminal window
./vendor/bin/sail artisan queue:flush

Warning: Use with caution in production!

List all failed jobs.

Terminal window
./vendor/bin/sail artisan queue:failed

Get detailed info:

Terminal window
./vendor/bin/sail artisan tinker
>>> $failed = DB::table('failed_jobs')->latest()->first();
>>> echo $failed->exception;

Delete all jobs from a queue.

Terminal window
./vendor/bin/sail artisan queue:clear database --queue=emails

Prune stale failed jobs.

Terminal window
# Prune jobs older than 24 hours (default)
./vendor/bin/sail artisan queue:prune-failed
# Prune jobs older than 7 days
./vendor/bin/sail artisan queue:prune-failed --hours=168

Prune stale batch records.

Terminal window
./vendor/bin/sail artisan queue:prune-batches --hours=720
Terminal window
# 1. Start development environment
./vendor/bin/sail up -d
# 2. Verify queue is working
./vendor/bin/sail artisan queue:test
# 3. Monitor queue status
./vendor/bin/sail artisan queue:monitor
# 4. Make code changes to job
vim app/Jobs/ProcessPayment.php
# 5. Restart workers to pick up changes
./vendor/bin/sail artisan queue:restart
# 6. Test your job
./vendor/bin/sail artisan tinker
>>> ProcessPayment::dispatch($orderId, 'credit_card');
# 7. Watch logs
./vendor/bin/sail artisan tail
Terminal window
# 1. List all failed jobs
./vendor/bin/sail artisan queue:failed
# 2. Get detailed error information
./vendor/bin/sail artisan tinker
>>> $failed = DB::table('failed_jobs')->latest()->first();
>>> echo $failed->exception;
# 3. Fix the underlying issue in code
# 4. Restart workers
./vendor/bin/sail artisan queue:restart
# 5. Retry the failed job
./vendor/bin/sail artisan queue:retry all
Terminal window
# 1. Deploy new code
git pull origin main
# 2. Install dependencies
composer install --no-dev --optimize-autoloader
# 3. Run migrations
php artisan migrate --force
# 4. Clear and rebuild cache
php artisan config:cache
php artisan route:cache
php artisan view:cache
# 5. Restart queue workers gracefully
php artisan queue:restart
# 6. Monitor queue health
php artisan queue:monitor

Queue is Stuck:

Terminal window
# 1. Check what's in the queue
./vendor/bin/sail artisan queue:monitor
# 2. Check worker status
docker ps | grep queue
# 3. Restart worker container
./vendor/bin/sail restart queue
# 4. If still stuck, clear queue (CAUTION!)
./vendor/bin/sail artisan queue:clear database --queue=default

Too Many Failed Jobs:

Terminal window
# 1. Investigate cause
./vendor/bin/sail artisan tinker
>>> DB::table('failed_jobs')->latest()->first()->exception;
# 2. Fix underlying issue
# 3. Retry if fixable
./vendor/bin/sail artisan queue:retry all
# 4. Or flush if not recoverable
./vendor/bin/sail artisan queue:flush
Terminal window
# Testing & Monitoring
queue:test # Dispatch test job
queue:monitor # Show queue status
queue:failed # List failed jobs
# Worker Management
queue:work # Start processing (in Docker)
queue:restart # Gracefully restart workers
# Failed Job Management
queue:retry all # Retry all failed jobs
queue:retry {id} # Retry specific job
queue:forget {id} # Delete failed job
queue:flush # Delete all failed jobs
# Maintenance
queue:clear # Clear pending jobs
queue:prune-failed # Remove old failed jobs
queue:prune-batches # Remove old batch records
# Logging & Debugging
artisan tail # Follow Laravel logs
logs queue # View worker logs (Sail)
tinker # Interactive console