Skip to content

Instantly share code, notes, and snippets.

@adeubank
Created August 29, 2018 18:21
Show Gist options
  • Save adeubank/4532eac63ecb6d124e0d49859d2958a7 to your computer and use it in GitHub Desktop.
Save adeubank/4532eac63ecb6d124e0d49859d2958a7 to your computer and use it in GitHub Desktop.
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