How to clear all the jobs from Sidekiq?
Solution 1:
You can do as it says on the issue 1077 or as reported in this blog at noobsippets
Both suggest we do the following, and can be done on rails console:
Sidekiq.redis(&:flushdb)
Caution: This command will clear all redis records. I suggest not using it in production
another approach would be
redis-cli --scan --pattern users: * | xargs redis-cli del
according to this blog
Solution 2:
Clear Sidekiq Jobs commands:
require 'sidekiq/api'
# Clear retry set
Sidekiq::RetrySet.new.clear
# Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# Clear 'Dead' jobs statistics
Sidekiq::DeadSet.new.clear
# Clear 'Processed' and 'Failed' jobs statistics
Sidekiq::Stats.new.reset
# Clear all queues
Sidekiq::Queue.all.map(&:clear)
# Clear specific queue
stats = Sidekiq::Stats.new
stats.queues
# => {"main_queue"=>25, "my_custom_queue"=>1}
queue = Sidekiq::Queue.new('my_custom_queue')
queue.count
queue.clear
Solution 3:
According to this issue on Github: https://github.com/mperham/sidekiq/issues/1732 you now need to
require 'sidekiq/api'