How to run Heroku Scheduler weekly

This post is a compliment to my Heroku Scheduler tutorial. By default, Heroku’s Scheduler addon only lets you run commands every 10 minutes, every hour, or daily. If you want to run Heroku Scheduler weekly, you can use this post.

After you’ve opened up Heroku Scheduler with heroku addons:open scheduler, create a new job. Set Schedule to “Every day at…” and set Run Command to one of the following, depending on which day you’d like your command to run:

if [ "$(date +%u)" = 1 ]; then YOURCOMMAND; fi # Monday
if [ "$(date +%u)" = 2 ]; then YOURCOMMAND; fi # Tuesday
if [ "$(date +%u)" = 3 ]; then YOURCOMMAND; fi # Wednesday
if [ "$(date +%u)" = 4 ]; then YOURCOMMAND; fi # Thursday
if [ "$(date +%u)" = 5 ]; then YOURCOMMAND; fi # Friday
if [ "$(date +%u)" = 6 ]; then YOURCOMMAND; fi # Saturday
if [ "$(date +%u)" = 7 ]; then YOURCOMMAND; fi # Sunday

All we’re doing is performing a conditional check to see if it’s the right day before running our command.

I'm Mark Thomas Miller, an engineer, designer, and maker of things.