Search code examples
ruby-on-railsruby-on-rails-3herokucronruby-on-rails-3.2

A pulse or cron job for Rails app running in Heroku


I need some code executed once per day. Can be more than once a day and missing a day isn't the end of the world. That code will make sure users get some bonus points based on certain criteria. I'll keep track if they've already received the bonus points so it doesn't double up..

Some simple cron job calling a particular controller once in a while is perfect:

curl http://localhost/tasks/pulse

Of course a real crontab entry works great. Or is there an internal mechanism for this kind of thing in Rails? I'm using the latest stable Rails (currently 3.2.9).

The only wrinkle is this needs to work in Heroku too.

I just noticed Heroku's Scheduler. Looks great for Heroku. I can just run those tasks in my dev/test environment manually. Is this the best way to handle pulses/cron jobs in Rails? With rake tasks? Easy to incorporate running rake tasks in tests?


Solution

  • The Heroku Scheduler works great and is easy to set up!