Commit 5694599a authored by Paul Cammish's avatar Paul Cammish
Browse files

Merge branch 'buster-testing' into 'buster'

buster-testing -> buster

See merge request sympl/sympl!112
parents 8a2baba0 237a1eca
sympl-cron (10.0.190719.0) stable; urgency=medium
* Updated sympl-crontab --test output
-- Paul Cammish <sympl@kelduum.net> Fri, 19 Jul 2019 12:07:00 +0100
sympl-cron (10.0.190621.0) stable; urgency=medium
* Created Sympl v10.0 (Debian Buster)
......
......@@ -31,26 +31,6 @@ require 'net/smtp'
require 'date'
require 'time'
#
# Additional methods for DateTime
#
class DateTime
#
# Return a string of self in the standard "YYYY-MM-DD hh:mm" format.
#
def iso8601
"%04i-%02i-%02i %02i:%02i" % [ year, month, day, hour, min ]
end
#
# Convert self into a Time.
#
def to_time
Time.local(year, month, day, hour, min, sec)
end
end
module Symbiosis
#
......@@ -123,19 +103,19 @@ module Symbiosis
#
def test(t = Time.now)
cron_env = @environment.merge(ENV){|k,o,n| o}
puts "Environment\n"+"-"*72
puts "Environment\n"+"-"*79
%w(HOME LOGNAME PATH MAILTO).each do |k|
puts "#{k} = #{cron_env[k]}"
end
puts "="*72+"\n\n"
puts "Jobs next due -- Local time #{t.iso8601}\n"+"-"*72
puts ("%-20s" % "Date" ) + "Command"
puts "-"*72
puts "="*79+"\n\n"
puts "Jobs next due -- Local time #{t.strftime('%Y-%m-%d %H:%M:%S')}\n"+"-"*79
puts ("%-20s" % "Next Run Time" ) + "Command"
puts "-"*79
@records.each do |record|
n = record.next_due(t)
puts ("%-20s" % (n.nil? ? "** NEVER **" : n.iso8601))+record.command
puts ("%-20s" % (n.nil? ? "** NEVER **" : n.strftime('%Y-%m-%d %H:%M')))+record.command
end
puts "="*72
puts "="*79
end
#
......@@ -297,6 +277,7 @@ module Symbiosis
# arguments fail to parse.
#
def initialize(min, hour, mday, mon, wday, command)
@min = parse_field(min, 0, 59)
@hour = parse_field(hour, 0, 23)
@mday = parse_field(mday, 1, 31)
......@@ -327,7 +308,6 @@ module Symbiosis
# Returns true if the record should be run at time set by now.
#
def ready?(now = Time.now)
now = now.to_time
if @lazy_mday_wday_match
min.include? now.min and
hour.include? now.hour and
......@@ -349,8 +329,9 @@ module Symbiosis
# time in the 30 years after now.
#
def next_due(now = Time.now)
time = now.to_time
time = now
orig_time = time
while !ready?(time)
# find the next minute that matches
......@@ -443,7 +424,14 @@ module Symbiosis
break
end
end
time
# We want the *next* time it'll run, rather than the time right now.
if ready?(orig_time)
time + 60
else
time
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment