Skip to content

Instantly share code, notes, and snippets.

@frankyston
Forked from wbotelhos/clear-sidekiq-jobs.sh
Created November 12, 2018 13:10
Show Gist options
  • Save frankyston/0e3317c5c797a3640cfba0a0f49b2d50 to your computer and use it in GitHub Desktop.
Save frankyston/0e3317c5c797a3640cfba0a0f49b2d50 to your computer and use it in GitHub Desktop.
Clear Sidekiq Jobs
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
Sidekiq::Stats.new.reset
# 3. Clear 'Dead' jobs statistics
Sidekiq::DeadSet.new.clear
# Via API
require 'sidekiq/api'
stats = Sidekiq::Stats.new
stats.queues
# {"production_mailers"=>25, "production_default"=>1}
queue = Sidekiq::Queue.new('queue_name')
queue.count
queue.clear
@frankyston
Copy link
Author

Sidekiq::Queue.all.each {|q| q.clear} is a handy way to clear all queues

@frankyston
Copy link
Author

As a side note, require 'sidekiq/api' must be first if you are in rails console

@frankyston
Copy link
Author

Yes! @wbotelhos that's a good idea
I was doing something wrong with Sidekiq::Testing.disable! i fixed and now works

https://user-images.githubusercontent.com/30449248/83050776-a701f400-a012-11ea-89f7-7cf0413ff910.png

Thanks a lot for u help!

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