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

1.1k views Asked by At

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

1

There are 1 answers

0
sharamb On

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.