# -*- encoding : utf-8 -*-
ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'production'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'rubygems'
require 'rufus/scheduler'
require 'rails'
require 'time'
scheduler = Rufus::Scheduler.start_new
scheduler.at Time.parse('2013-09-27 23:30:00') do
#scheduler.in '1s' do
CmsTvSubject.find(63).update_attributes(:state => 1)
Rails.logger.info " == job done"
end
scheduler.at Time.parse('2013-09-29 23:30:00') do
CmsTvSubject.find(64).update_attributes(:state => 1)
end
scheduler.at Time.parse('2013-09-30 23:30:00') do
CmsTvSubject.find(65).update_attributes(:state => 1)
end
scheduler.at Time.parse('2013-10-2 23:30:00') do
CmsTvSubject.find(66).update_attributes(:state => 1)
end
scheduler.at Time.parse('2013-10-4 23:30:00') do
CmsTvSubject.find(67).update_attributes(:state => 1)
end
scheduler.at Time.parse('2013-10-6 23:30:00') do
CmsTvSubject.find(68).update_attributes(:state => 1)
end
scheduler.join
Rufu Scheduler的at,只能用time格式(onlyuseaspecifictimeformatinrufuscheduler'sat)
如题。
下面是个例子:
This post is licensed under
CC BY 4.0
by the author.