How do I schedule recurring jobs in Active Job (Rails 4.2)?

前端 未结 4 1717
庸人自扰
庸人自扰 2020-12-15 16:06

I found this Schedule one-time jobs in Rails but this only shows how schedule one-time. I am interested in scheduling a recurring job.

Delayed_job has this

4条回答
  •  别那么骄傲
    2020-12-15 16:30

    You can just re-enqueue the job at the end of the execution

    class MyJob < ActiveJob::Base
      RUN_EVERY = 1.hour
    
      def perform
        # do your thing
    
        self.class.perform_later(wait: RUN_EVERY)
      end
    end
    

提交回复
热议问题