Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear all the jobs from Sidekiq?

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


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 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

According to this issue on Github: https://github.com/mperham/sidekiq/issues/1732 you now need to

require 'sidekiq/api'

As of latest Sidekiq, just blow it up:

require 'sidekiq/api'

q = Sidekiq::Queue.new
q.💣

Yes, the command to clear all is literally a bomb emoji. Also works for Sidekiq::RetrySet.

Or if you're no fun you can use q.clear


redis-cli flushdb

You can also use redis-cli flushall