Skip to content

Instantly share code, notes, and snippets.

@wting
Last active August 29, 2015 14:02
Show Gist options
  • Save wting/132d78f95019a5d22ab5 to your computer and use it in GitHub Desktop.
Save wting/132d78f95019a5d22ab5 to your computer and use it in GitHub Desktop.
Runs a command continuously (e.g. rsync) until it succeeds (0 exit code).
#!/usr/bin/bash
nevergonnagiveyouup() {
false
while [ $? -ne 0 ]; do
${@}
if [ $? -ne 0 ]; then
echo "[$(\date +%Y.%m.%d_%H%M)] FAIL: trying again in 60 seconds..."
sleep 60
false
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment