Last active
December 20, 2015 03:19
-
-
Save emilisto/6062551 to your computer and use it in GitHub Desktop.
Little bash script that re-runs a command until it exits with code 0, i.e. runs successfully. I get impatient when SSH'ing to new servers...
This file contains hidden or 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
#!/bin/bash | |
# Examples: | |
# | |
# When's the damn thing online? | |
# | |
# $ retry.sh ssh [email protected] | |
# | |
# When's internet back? | |
# | |
# $ retry.sh ping -c 1 google.com | |
# | |
ret=1 | |
while [[ $ret -ne 0 ]]; do | |
$@ | |
ret=$? | |
if [[ $ret -ne 0 ]]; then | |
sleep 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment