How to clear all tasks from sidekiq?

I am using sidekiq for background tasks in a Rails application. Now the number of tasks is getting larger, so I want to clear all the tasks. I tried the following command in the console

Sidekiq::Queue.new.clear 

but he gave the following error.

 NameError: uninitialized constant Sidekiq::Queue 

How to clear all tasks from sidekiq?

+89
ruby ruby-on-rails sidekiq
Jul 22 '14 at 11:37
source share
8 answers

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

 require 'sidekiq/api' 
+55
Jul 22 '14 at 12:13
source share

You can do as the 1077 says or as reported on this blog by noobsippets

Both suggest that we do the following and can do this on the rails console:

Sidekiq.redis { |conn| conn.flushdb }

+169
Feb 11 '16 at 19:59
source share

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 
+55
Jul 30 '16 at 8:59
source share

Starting with the last Sidekiq, just blow it up:

 require 'sidekiq/api' q = Sidekiq::Queue.new q.💣 

Yes, the team to clear it all is literally an emoji bomb. Also works for Sidekiq::RetrySet .

Or if you are not having fun, you can use q.clear

+19
Dec 07 '17 at 17:37
source share
 redis-cli flushdb 

You can also use redis-cli flushall

+15
Aug 30 '17 at 5:50
source share

Use Rails Runner on one line

 rails runner 'Sidekiq.redis { |conn| conn.flushdb }' 
+7
Aug 28 '18 at 5:00
source share

All Sidekiq quests are stored in Redis.

You can remove "Redis" with this command

 redis-cli flushall 
+2
May 18 '19 at 2:03
source share

You can use this to clean all jobs.

 require 'sidekiq/api' Sidekiq::Queue.all.each(&:clear) 
0
Jun 07 '19 at 5:56 on
source share



All Articles