Last active
December 25, 2022 22:08
-
-
Save jamescherti/995add1dcbf3080dfa25cf372287cca9 to your computer and use it in GitHub Desktop.
Shell: Retry a command until it succeeds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Description: Retry a command until it succeeds. | |
# Author: James Cherti | |
# License: MIT | |
# URL: https://gist.github.com/jamescherti/995add1dcbf3080dfa25cf372287cca9 | |
echo "[RUN] $*" >&2 | |
while true; do | |
if "$@"; then | |
break | |
else | |
sleep 1 | |
echo "[RUN AGAIN] $*" >&2 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment