Running cron jobs on Heroku
Heroku has an add-on, Heroku Scheduler, you can use to run processes typically run via cron. This gives you a “limited” ability of scheduling jobs. I say limited because you definitely don’t have the flexibility of scheduling like you do when using cron.
You can schedule the run frequency to be:
- 10 minutes
And you can set the next run time to be:
- on the hour
- on the 1/2 hour
They also have a big caveat in that the scheduled processes aren’t guaranteed to run, so don’t use this for mission critical jobs!
Scheduler is a “best effort” service, meaning that execution is expected but not guaranteed. Scheduler is known to occasionally (but rarely) miss the execution of scheduled jobs. If scheduled jobs are a critical component of your application, it is recommended to run a custom clock process instead for more reliability, control, and visibility.
If you have simple non-critical tasks that don’t have complicated scheduling, this is a really easy way to run them.
I have a few python scripts that I’ve scheduled to run using Heroku Scheduler. This is the command I use to get them to run:
Of course, verify they’re running by checking your logs.