Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
Created November 2, 2013 17:36
Show Gist options
  • Save jugglinmike/7281434 to your computer and use it in GitHub Desktop.
Save jugglinmike/7281434 to your computer and use it in GitHub Desktop.
Continuously re-run a process, logging failures (troubleshooting flaky integration tests)
#!/usr/bin/env bash
# Continuously re-run a process, logging failures
RUNCOUNT=0
FAILCOUNT=0
COMMAND=$1
while [ 1 ]
do
if [ $(($RUNCOUNT % 10)) -eq 0 ]
then
echo Now starting run \#$RUNCOUNT
fi
eval $COMMAND 2> failure-${FAILCOUNT}.txt > /dev/null
if [ $? -ne 1 ]
then
echo Run \#$RUNCOUNT failed \(failure \#$FAILCOUNT\) at `date`
FAILCOUNT=$(($FAILCOUNT + 1))
fi
RUNCOUNT=$((RUNCOUNT + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment