Skip to content

Instantly share code, notes, and snippets.

@tfluehmann
Last active June 22, 2016 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfluehmann/8807ce5d4ada60c57a39ddbbb9c131d5 to your computer and use it in GitHub Desktop.
Save tfluehmann/8807ce5d4ada60c57a39ddbbb9c131d5 to your computer and use it in GitHub Desktop.
reschedule sidekiq cron jobs
scheduled_jobs = YAML.load_file('schedule.yml')
existing_jobs = Sidekiq::Cron::Job.all
existing_jobs.delete_if{|job| !job.name.downcase.match(/^my_pattern\_/)}
existing_jobs.each do |job|
queue = job.instance_variable_get(:@queue)
new_hash = {class: job.klass, cron: job.cron, description: job.description, args: job.args, status: job.status, queue: queue}
scheduled_jobs[job.name] = new_hash
end
Sidekiq::Cron::Job.load_from_hash!(scheduled_jobs )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment