Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all scheduled task in Sidekiq

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 ?

like image 499
Thyda Eng Avatar asked Oct 07 '16 08:10

Thyda Eng


People also ask

Is Sidekiq a FIFO?

Sidekiq reads jobs from a Redis queue, using the First In First Out (FIFO) model, to process jobs.

Is Async a Sidekiq?

Sidekiq gem is used to move long running jobs to background for asynchronous processing. It is more efficient, with respect to memory usage, than delayed_job and Resque as it uses threads instead of forks.


2 Answers

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

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

Check out Sidekiq API.

like image 102
Andrey Deineko Avatar answered Oct 13 '22 21:10

Andrey Deineko


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)
like image 38
Aleks Avatar answered Oct 13 '22 22:10

Aleks