Skip to content

Instantly share code, notes, and snippets.

@xlson
Created April 29, 2011 16:04
Show Gist options
  • Save xlson/948532 to your computer and use it in GitHub Desktop.
Save xlson/948532 to your computer and use it in GitHub Desktop.
Executes a command over and over until the command returns a non-zero exit code. Useful for running tests that should be, but aren't, deterministic.
#!/bin/bash
COMMAND=$1
i=0
echo "Executing: $COMMAND"
while true; do
i=$[$i+1]
echo "Run: $i ("`date`")"
$COMMAND 2>&1 1> run.log
if [ $? -ne 0 ]; then
echo "Command failed!"
break
fi
done
echo "Exiting."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment