Skip to content

Instantly share code, notes, and snippets.

@LogaJ
Forked from wbotelhos/clear-sidekiq-jobs.sh
Last active February 5, 2020 07:34
Show Gist options
  • Save LogaJ/4099c80db1f768cd6d5668bedd588898 to your computer and use it in GitHub Desktop.
Save LogaJ/4099c80db1f768cd6d5668bedd588898 to your computer and use it in GitHub Desktop.
Clear Sidekiq Jobs
#require 'sidekiq/api'
# 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
stats = Sidekiq::Stats.new
stats.queues
# {"foo"=>25, "bar"=>1}
stats.queues.keys.map {|q| Sidekiq::Queue.new(q).count}
# [6,2]
stats.queues.keys.each {|q| Sidekiq::Queue.new(q).clear}
# ["foo", "bar"]
stats.queues.keys.map {|q| Sidekiq::Queue.new(q).count}
# []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment