Ruby-on-rails – How to clear all the jobs from Sidekiq

rubyruby-on-railssidekiq

I am using sidekiq for background tasks in Rails application. Now the numbers of jobs becomes more, so I want to clear all the jobs. I tried the following command in console

Sidekiq::Queue.new.clear

but it was giving following error.

NameError: uninitialized constant Sidekiq::Queue 

How do I clear all the jobs from sidekiq?

Best Answer

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

Related Topic