Class: Makesure::Cron
- Inherits:
-
Object
- Object
- Makesure::Cron
- Defined in:
- lib/makesure/cron.rb
Instance Method Summary collapse
- #build_crontab_output ⇒ Object
-
#initialize(opts = {}) ⇒ Cron
constructor
specify a file (or directory containing files) to load system specifications from.
Constructor Details
#initialize(opts = {}) ⇒ Cron
specify a file (or directory containing files) to load system specifications from
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/makesure/cron.rb', line 6 def initialize(opts = {}) opts = { :cron_path => "/etc/cron.d/makesure.cron" }.merge(opts) Makesure.log "updating '#{opts[:cron_path]}'" cron_file = File.(opts[:cron_path]) crontab = build_crontab_output Makesure.debug "#{cron_file}:\n#{crontab}" File.open(cron_file, "w") do |f| f.write(crontab) end end |
Instance Method Details
#build_crontab_output ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/makesure/cron.rb', line 22 def build_crontab_output crontab = "" crontab << "# Autogenerated by makesure: you probably don't want to edit this file\n" Makesure.systems.each do |s| uid = s.uid || Makesure.uid crontab << "\n" crontab << "## Tasks for '#{s.name}'\n" crontab << "# Commands\n" s.cmds.each do |c| crontab << "#{c.cron}\t" crontab << "#{uid} " if uid crontab << "makesure-runner run #{c.command.inspect}\n" end crontab << "# Verification\n" s.verifies.each do |v| crontab << "#{v.cron}\t" crontab << "#{uid} " if uid crontab << "makesure-runner verify #{s.name} #{v.name}\n" end # TODO summarizes end crontab end |