我正在试着为一个周期性的工作设置时钟。(Rails4.2)下面的代码来自app/clock.rb中的gem read-me,每隔30秒就会触发一次后台任务并发送电子邮件。
require 'clockwork'
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
module Clockwork
handler do |job, time|
puts "Running #{job} , at #{time}"
end
#History is a class method which runs the logic and ques the job
every(30.seconds, 'send_history.job'){History.recur}
end如果我将递归语句替换为以下语句,则它不起作用。
every(1.day, 'send_history.job', :at => '22:00'){History.recur}有什么想法吗?我搜索了其他有这个问题的人,但没有找到任何人。我正在使用活动作业的delayed_job来完成任务。谢谢
发布于 2015-06-25 12:58:59
我让它起作用了。我没有输入我感兴趣的时区(UTC)。作业正在等待本地时区的时间。我输入tz:"UTC“,它起作用了。
https://stackoverflow.com/questions/31040352
复制相似问题