Skip to content

Instantly share code, notes, and snippets.

@khairulcs
Forked from wbotelhos/clear-sidekiq-jobs.sh
Last active May 25, 2021 13:23
Show Gist options
  • Save khairulcs/fc8bb81b34b796469b961f634d14aa97 to your computer and use it in GitHub Desktop.
Save khairulcs/fc8bb81b34b796469b961f634d14aa97 to your computer and use it in GitHub Desktop.
Clear Sidekiq Jobs

1. Clear retry set

Sidekiq::RetrySet.new.clear

1.1 Retry all

Sidekiq::RetrySet.new.retry_all

2. Clear scheduled jobs

Sidekiq::ScheduledSet.new.clear

3. Clear 'Processed' and 'Failed' jobs

Sidekiq::Stats.new.reset

4. Clear 'Dead' jobs statistics

Sidekiq::DeadSet.new.clear

Stats

stats = Sidekiq::Stats.new
stats.queues

{"production_mailers"=>25, "production_default"=>1}

Queue

queue = Sidekiq::Queue.new('queue_name')
queue.count
queue.clear
queue.each { |job| job.item } # hash content

Redis Acess

Sidekiq.redis { |redis| redis.keys }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment