Created
June 25, 2015 14:56
-
-
Save shoaibi/e42b2ab4f6f2754293f3 to your computer and use it in GitHub Desktop.
Keep retrying some job till it executes successfully
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
#!/bin/bash | |
# Keep retrying some job till it executes successfully | |
# | |
# I primarily use this script to download files from servers | |
# that break the connection after certain minutes. Combining | |
# this with aria2c makes a really awesome sure-fire way to | |
# download your files. | |
# | |
carryOutJob() | |
{ | |
DONE=30 | |
job="$1" | |
until [ $DONE -eq 0 ]; do | |
echo "starting: $job" | |
$job | |
DONE=$(echo $?) | |
# You may add some sleep over here | |
done | |
} | |
E_BADARGS=65 | |
echo | |
if [ $# -ne 1 ] | |
then | |
echo "Usage: $0 {job}" | |
exit $E_BADARGS | |
fi | |
carryOutJob "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment