Last active
June 22, 2016 06:23
-
-
Save tfluehmann/8807ce5d4ada60c57a39ddbbb9c131d5 to your computer and use it in GitHub Desktop.
reschedule sidekiq cron jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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