Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deleting Sidekiq Jobs From Queue, Scheduled, and Retry
# find them in a queue
queue = Sidekiq::Queue.new("default")
jobs = queue.map do |job|
if job.klass == '[JOB_CLASS]'
{job_id: job.jid, job_klass: job.klass, arguments: job.args}
end
end.compact
# the retry queue
retries = Sidekiq::RetrySet.new.select
jobs = retries.map do |job|
if job.klass == '[JOB_CLASS]'
{job_id: job.jid, job_klass: job.klass, arguments: job.args}
end
end.compact
# the scheduled queue
scheduled = Sidekiq::ScheduledSet.new.select
jobs = scheduled.map do |job|
if job.klass == '[JOB_CLASS]'
{job_id: job.jid, job_klass: job.klass, arguments: job.args}
end
end.compact
# delete jobs with `job.delete`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment