Skip to content

Instantly share code, notes, and snippets.

@covard
Created January 12, 2023 21:21
Show Gist options
  • Save covard/f5befcfbefd27dcba9cb3c08255d48ba to your computer and use it in GitHub Desktop.
Save covard/f5befcfbefd27dcba9cb3c08255d48ba to your computer and use it in GitHub Desktop.
Sidekiq dead queue cleanup by date. Sidekiq dead queue created_at to actual date.

Sidekiq Dead Queue / Set

The sidekiq dead queue object has a an item['created_at'] that is an decimal (of unknown meaning is it julian? is it seconds is it a unix time stamp?) However on the object there is a method for created_at that will return a Date object.

ds = Sidekiq::DeadSet.new
size = ds.size
ds.each_with_index do |job- indx|
  print "\r #{indx} of #{size}"
  if job.created_at.to_datetime <= 1.month.ago
    job.delete
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment