#TIL: Writing a Heroku Pinger to keep your free dynos alive

With the free tier for Heroku, your app dyno sleeps after 30 mins and must sleep for 6 hours in a 24 hour period. If anyone hits your website after the dyno goes to sleep they have to wait a long time as the dyno comes back to life. To prevent this you can have a cron job run periodically that hits your heroku hosted website.

$ crontab -e

This will run every 5 minutes on specific hours (you want your dyno to sleep when you do)

# Run every 5 mins
*/5 6-23 * * * bash /home/..../app_heroku_pinger.sh

Here’s the shell script

#app_heroku_pinger.sh
#!/bin/bash
curl -L your_app.herokuapp.com