How to clear all the jobs from Sidekiq?

Can Can picture Can Can · Jul 22, 2014 · Viewed 73k times · Source

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?

Answer

jonathanccalixto picture jonathanccalixto · Feb 11, 2016

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