how to delete a job in sidekiq

According to this Sidekiq documentation page to delete a job with a single id you need to iterate the queue and call .delete on it.

queue = Sidekiq::Queue.new("mailer")
queue.each do |job|
  job.klass # => 'MyWorker'
  job.args # => [1, 2, 3]
  job.delete if job.jid == 'abcdef1234567890'
end

There is also a plugin called sidekiq-status that provides you the ability to cancel a single job

scheduled_job_id = MyJob.perform_in 3600
Sidekiq::Status.cancel scheduled_job_id #=> true

Leave a Comment