简体   繁体   中英

clockwork gem not running the job when :at => “some time” is given

I am trying to setup clockwork for a recurring job. (Rails 4.2) The following code from the gem read-me in app/clock.rb works and every 30 seconds the background task is fired and email is sent.

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

If I replace the recurring statement to the following then it doesn't work.

 every(1.day, 'send_history.job', :at => '22:00'){History.recur}

Any thoughts? I searched for others with this issue but couldn't find any. I am using delayed_job with Active job for queing. thanks

I got it to work. I was not putting the timezone I was interested in (UTC). The job was waiting for the time in local timezone. I put in tz: "UTC" and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM