Delete all scheduled task in Sidekiq
Asked Answered
A

3

6

I am working with rails and have the bunch of schedule tasks running on sidekiq, and anyway I want to delete all of that tasks from schedule list. I was wonder whether is there any command with rails I can run to clear all those stuff ?

Ay answered 7/10, 2016 at 8:38 Comment(0)
C
14

There is. Given that your queue is called "my_queue":

require 'sidekiq/api'
Sidekiq::ScheduledSet.new("my_queue").clear

Check out Sidekiq API.

Clepsydra answered 7/10, 2016 at 8:39 Comment(0)
C
10

The accepted answer didn't work for me. What I did to clear the queue was:

Sidekiq::ScheduledSet.new.clear

If you need clearing the scheduled queue, you might need also clearing other queues:

Sidekiq::RetrySet.new.clear
Sidekiq::Queue.new("your_queue_name").clear
Sidekiq::Queue.all.each(&:clear)
Charlena answered 17/2, 2019 at 9:33 Comment(6)
I can confirm this.Leatherjacket
Yep, this is the correct answer with fresh Sidekiq versions. I edited the original answer a bit (I hope it goes through).Aureolin
@TimoSaloranta You can't just edit one answer, and completely change it to some ones else's answer. You can make it more clear, but not change the whole idea behind it. One answer might work for someone in some other cases or gem versions, which is why one answer has one number of votes and the second one has different number of up-votesCharlena
@Charlena Point taken. Anyway, the accepted answer had not been working for a very long while (I have bumped into this exact question several times during the past few years). That's why I see no reason leaving it hanging over there because it's clearly outdated.Aureolin
@TimoSaloranta The original author might have changed to "accepted" answer before the change, but now you made two answers exactly the same.Charlena
@aleks You are right, I had misunderstood how to work with outdated answers. It's discussed in this meta. meta.stackexchange.com/questions/180864/… As you understand, my aim was to get the right up-to-date answer (effectively the one-line fix you could also have provided to the original answerer as a comment) more visible but this was clearly wrong way to achieve that. Reviewer of my edit also made the same wrong interpretation so it seems it's not very clear to everyone else either. Thanks for pointing this out!Aureolin
V
0

Neither of the listed solutions worked for me so I had to shut down redis-server and sidekiq and delete the dump.rdb file. Keep in mind, doing this will delete all queues, all the retries, and the lists of processed, failed and dead jobs.

Venerate answered 23/2, 2022 at 19:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.