简体   繁体   中英

How to get cron job working in heroku (production)

So I have the following in my schedule.rb - I'm using the whenever gem

set :output, "#{path}/log/cron.log"
job_type :script, "'#{path}/script/:task' :output"

every :sunday, at: "3:00 AM" do
  runner "Event.clear_expired"
end

And I'd like to have this running in production on Heroku.

How might I set it up?

I've looked at a couple like scheduler etc.. but they seem really un-intuitive.. any guidance would be helpful!

Update :

task :weeklydelete do
  set :output, "#{path}/log/cron.log"
  job_type :script, "'#{path}/script/:task' :output"

  every :sunday, at: "3:00 AM" do
  runner "Event.clear_expired"
  end

end

You need the Heroku Scheduler addon, which is free, and then you can set your job up in there. You can't use whenever on Heroku.

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