I recently wrote some code to handle this, it is available in my sidekiq-status attribute branch. You can view it or use it here: https://github.com/Robinson7D/sidekiq-status
(You should use this as git: information git: in the gemfile, for now, until the main project fork implements this)
To use it, you first save the job_identifier identifier:
job_identifier = MyWorker.perform_at(3.hours.from_now, 'mike', 1)
And when you want to destroy it, you call the Sidekiq :: Status.cancel method:
Sidekiq::Status.cancel job_identifier
Edit: since writing this post, my code has been accepted in the Sidekiq :: Status main fork - https://github.com/utgarda/sidekiq-status . You no longer need to use your plug. On Utgardβs fork, you will call him, calling inhumanly, instead of canceling:
Sidekiq::Status.unschedule job_identifier
Next: you can also delete tasks using the standard Sidekiq stone, as described here: https://github.com/mperham/sidekiq/wiki/API (although for their methods you need unix-timestamp when the task is scheduled - you cannot delete only with the task ID, if you want to delete the task without a time stamp, the Sidekiq :: Status method may be right for you).
However, instead of what they describe in the wiki, I would recommend something along the lines of Sidekiq::ScheduledSet.new().delete(unix_timestamp, jid) if you want to delete only one job.)
DRobinson Jul 26 '13 at 1:17 2013-07-26 01:17
source share