Skip to content

Instantly share code, notes, and snippets.

@jgraham909
Created November 16, 2015 18:48
Show Gist options
  • Save jgraham909/db3f597a791f8685e204 to your computer and use it in GitHub Desktop.
Save jgraham909/db3f597a791f8685e204 to your computer and use it in GitHub Desktop.
One line retry with exponential backoff
#!/bin/bash
# Currently runs "make deploy" just change that to whatever you want
(MAXTRIES=4; COUNT=0; BACKOFF=1; while [ $COUNT -lt $MAXTRIES ]; do (make deploy); if [ $? -eq 0 ];then exit 0; fi; let COUNT=COUNT+1; let BACKOFF=BACKOFF*2; echo "Attempt $COUNT failed retrying after $BACKOFF seconds"; sleep $BACKOFF; done; echo "Tried and failed $COUNT times. Giving up."; exit 1;)
@jgraham909
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment