Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Heroku scheduled restarts
#!/bin/sh
# Set up the Heroku scheduler to run this command every hour. See example setup at https://goo.gl/nMCSH3
#
# Requires env vars to be set in Heroku with `heroku config:set`:
# - HEROKU_APP_NAME: this is just the app name in Heroku, i.e. `heroku apps` will list all apps you have access to
# - HEROKU_CLI_USER: Once Heroku CLI is authenticated (https://goo.gl/Qypr4x), check `cat .netrc` (or `_netrc` on Windows),
# look for `login` under `machine api.heroku.com`
# - HEROKU_CLI_TOKEN: As above, but use the `password` field
#
# It helps if this file has execute privileges `chmod +x restart.sh`
#
# Test this script works by running `heroku run "~/restart.sh"`
#
# Heroku API: Restart all Dynos, see https://devcenter.heroku.com/articles/platform-api-reference#dyno-restart-all
curl -X DELETE "https://api.heroku.com/apps/${HEROKU_APP_NAME}/dynos" \
--user "${HEROKU_CLI_USER}:${HEROKU_CLI_TOKEN}" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3"
@shadyshrif

This comment has been minimized.

Copy link

@shadyshrif shadyshrif commented Nov 13, 2019

Thanks this worked for me!

@mattheworiordan

This comment has been minimized.

Copy link
Owner Author

@mattheworiordan mattheworiordan commented Nov 15, 2019

Thanks this worked for me!

Nice 👍

@ashwin1111

This comment has been minimized.

Copy link

@ashwin1111 ashwin1111 commented Feb 17, 2020

❤️

@mrquangkhai98

This comment has been minimized.

Copy link

@mrquangkhai98 mrquangkhai98 commented Mar 3, 2020

The example setup file is 404, please update, thanks in advance!

@ESWZY

This comment has been minimized.

Copy link

@ESWZY ESWZY commented Apr 16, 2020

🥰

@ESWZY

This comment has been minimized.

Copy link

@ESWZY ESWZY commented Apr 16, 2020

Run perfectly with chmod +x restart.sh ; ./restart.sh

@Unicorndy

This comment has been minimized.

Copy link

@Unicorndy Unicorndy commented Apr 24, 2020

I tried running the heroku run "~/restart.sh", But it gave me permission denied.
I have set chmod +x restart.sh, but its still not working. Anyone else have this issue?

@ESWZY

This comment has been minimized.

Copy link

@ESWZY ESWZY commented Apr 24, 2020

I tried running the heroku run "~/restart.sh", But it gave me permission denied.
I have set chmod +x restart.sh, but its still not working. Anyone else have this issue?

try chmod +x restart.sh ; ./restart.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.