Skip to content

Instantly share code, notes, and snippets.

@hggh
Created March 20, 2014 09:40
Show Gist options
  • Save hggh/9660326 to your computer and use it in GitHub Desktop.
Save hggh/9660326 to your computer and use it in GitHub Desktop.
crontab checker in ruby
#!/usr/bin/ruby
require 'cron-spec'
File.read("/tmp/cron").split("\n").each do |line|
next if line =~ /^#/ or line =~ /^$/
data = line.split(" ")
cron_time = data[0..4].join(" ")
begin
cs = CronSpec::CronSpecification.new(cron_time)
rescue Exception => e
puts e.message
puts "Line has problems: #{line}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment