1 2 # Function to force a command to try until it works. 3 # Name means "JUST #@$% DO IT!" 4 JFDI () { 5 COMMAND=$* 6 while ! $COMMAND ; do echo "Retrying..." ; done 7 }
Using it is simplicity itself:
1 2 # command that can fail and annoy 3 rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/ 4 5 # command that won't give up ever 6 JFDI rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/