scheduling a job every minute Rails 3.1 on Heroku

三世轮回 提交于 2019-11-30 09:17:22

You could use delayed_job with a self-restarting job with a :run_at. Something sort of like this:

class YourJob
    def do_interesting_things
        #... Do what needs to be done.
        self.delay(:run_at => 1.minute.from_now).do_interesting_things
    end

    def self.start_me_up
        new.do_interesting_things
    end
end

And then somewhere during your application's initialization:

YourJob.start_me_up

As of today, you can the scheduling gem, clockwork. Heroku officially supports this and you can find their documentation here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!