Is there a ruby gem/plugin which will convert something like */10 * * * 1,3 to "Triggers every 10 minutes on Monday, Wednesday" ?
There's nothing I know of and I also didn't find anything with Google. You may be able to hack something together on your own though:
>> cron = "*/10 * * * 1,3 foo"
#=> "*/10 * * * 1,3 foo"
>> min, hour, dom, month, dow, command = cron.split
#=> ["*/10", "*", "*", "*", "1,3", "foo"]
Once you have the vars, you can start assembling the parts for your output:
>> require 'date'
#=> true
>> dow.split(/,/).map { |day| Date::DAYNAMES[day.to_i] }
#=> ["Monday", "Wednesday"]
>> min.start_with?('*') ? "every #{min.split('/')[1]} minutes" : "#{min} past"
#=> "every 10 minutes"
>> min = '5'
#=> "5"
>> min.start_with?('*') ? "every #{min.split('/')[1]} minutes" : "#{min} past"
#=> "5 past"
Obviously that's just some rough ideas (for example you may want a regex with capture groups for parsing the entry), but since the crontab entries are well specified, it shouldn't be too hard to come up with something that works for most of the entries you are likely to encounter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With