1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#!/bin/bash
if [ -z "$1" ] ; then
echo "usage: $0 <command>"
echo ""
echo "example: $0 ./failer 3"
exit 1
fi
loopit=0
sleeptime=10
while ! $* ; do
# we reset the terminal:
reset
loopit=$(( $loopit + 1 ))
echo "Failure number $loopit. Sleeping $sleeptime seconds and retring"
sleep $sleeptime
done
if [ $loopit -eq 0 ] ; then
echo "The command [$*] has completed without retry"
else
printf "The command [$*] has completed but needed $loopit retr"
if [ $loopit -gt 1 ] ; then
echo "ies"
else
echo "y"
fi
fi
|