root/lang/ruby/xrea-cron/lib/cron.rb @ 15802

Revision 15802, 365 bytes (checked in by ishihara, 6 years ago)

initial import

Line 
1require 'cron/crontab'
2
3module Cron
4  class << self
5    def run(path, time = Time.now)
6      Crontab.parse(File.read(path)).each do |line|
7        execute(line, time)
8      end
9    end
10
11    private
12      def execute(line, time)
13        execute!(line) if line.execute?(time)
14      end
15
16      def execute!(line)
17        fork { exec line.command }
18      end
19  end
20end
Note: See TracBrowser for help on using the browser.