"Whenever" gem running cron jobs on Heroku "Whenever" gem running cron jobs on Heroku ruby ruby

"Whenever" gem running cron jobs on Heroku


Short answer: use the scheduler add-on: http://addons.heroku.com/scheduler

Long answer: When you do heroku run, we

  1. spin up a dyno
  2. put your code on it
  3. execute your command, wait for it to finish
  4. throw the dyno away

Any changes you made to crontab would be immediately thrown away. Everything is ephemeral, you cannot edit files on heroku, just push new code.


You need to add Heroku Scheduler addon.

You can add it directly from your dashboard or using following commands:

  1. install the add-on:

    heroku addons:create scheduler:standard
  2. Create a rake task in lib/tasks

    # lib/tasks/scheduler.raketask :send_reminders => :environment do  User.send_remindersend
  3. Schedule job

    • Visit Heroku Dashboard
    • Open your app
    • Select Scheduler from add-ons list
    • Click Add Job, enter a task and select frequency.

      e.g. Add rake send_reminders, select "Daily" and "00:00" to send reminders every day at midnight.

Heroku add cron task


The other answers specify you should use the Heroku Scheduler add-on, and it is able to run a background tasks indeed, but it doesn't support the flexibility of cron.

There's another add-on, called Cron To Go, that is able to run your jobs on one-off dynos with cron's flexibility. You can also specify a timezone for your job and get notifications (email or webhook) when job fail, succeed or start.

(Full disclosure - I work for the company that created and operates Cron To Go)