A simple way 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.

About the author

I'm Mark Thomas Miller, a full stack engineer and designer currently working at ConvertKit. (We're hiring!) People like Arnold Schwarzenegger, Lindsey Stirling, and Tim Ferriss use features I've built to connect with their fans. I'm currently geeking out about Svelte, mechanical keyboards, and minimalist UI design, and replaying Ocarina of Time.