Scron::Schedule
Inherits Reference < Object
Wraps a single line in the schedule file. Made up of two parts, the interval and the command. Determines if a command is overdue and needs to be run. Does this by translating interval string into number of days since last run until command is considered overdue.
Constants
WEEKDAYS = {"Mo" => 1, "Tu" => 2, "We" => 3, "Th" => 4, "Fr" => 5, "Sa" => 6, "Su" => 7}
Constructors
new(line : String, now : Time)
Returns a schedule with an interval and command. Example usage:
Scron::Schedule.new("Mo,We echo", Time.local) # run every Monday/Wednesday
Scron::Schedule.new("23rd echo", Time.local) # run on the 23rd of every month
Scron::Schedule.new("12/25 echo", Time.local) # run on December 25th every year
Scron::Schedule.new("10d echo", Time.local) # run once every 10 days
Class methods
Given the text of a schedule file, parses it and returns an Array of Schedules.
Lines prefixed with # are ignored as a comment. Empty lines are also ignored.
Instance methods
command
Sourceinterval
Sourceoverdue?(history : History)
Returns true if command should run now, if it satisfies any of these conditions:
- command has never ran
- interval is past due, example: it last ran 15 days ago but the interval is every 14 days