the future is in beta

home about

Change Delayed::Job default retry interval

14 Aug 2013

By default Delayed::Job sets the interval between retries using this formula increasing in time:

next_time = last_time + (attempts ** 4) + 5

As Greg Lazarev points out in this anwser you can modify the default interval defining a reschedule_at method in your class. For example:

@video = Video.new
@video.delay.track_encoding

Where this is the Video model:

class Video
  def track_encoding
    # your background job code here
  end
  def reschedule_at(attemtps, time)
    Time.now + 3600 * 2 # 2 hours from now
  end
end

This is the Delayed::Job source code: base.rb