1retry - The command line retry tool 2------------------------------------------ 3 4Retry any shell command with exponential backoff or constant delay. 5 6### Instructions 7 8Install: 9 10retry is a shell script, so drop it somewhere and make sure it's added to your $PATH. Or you can use the following one-liner: 11 12```sh 13sudo sh -c "curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o /usr/local/bin/retry && chmod +x /usr/local/bin/retry" 14``` 15 16If you're on OS X, retry is also on Homebrew: 17 18``` 19brew pull 27283 20brew install retry 21``` 22Not popular enough for homebrew-core. Please star this project to help. 23 24### Usage 25 26Help: 27 28`retry -?` 29 30 Usage: retry [options] -- execute command 31 -h, -?, --help 32 -v, --verbose Verbose output 33 -t, --tries=# Set max retries: Default 10 34 -s, --sleep=secs Constant sleep amount (seconds) 35 -m, --min=secs Exponential Backoff: minimum sleep amount (seconds): Default 0.3 36 -x, --max=secs Exponential Backoff: maximum sleep amount (seconds): Default 60 37 -f, --fail="script +cmds" Fail Script: run in case of final failure 38 39### Examples 40 41No problem: 42 43`retry echo u work good` 44 45 u work good 46 47Test functionality: 48 49`retry 'echo "y u no work"; false'` 50 51 y u no work 52 Before retry #1: sleeping 0.3 seconds 53 y u no work 54 Before retry #2: sleeping 0.6 seconds 55 y u no work 56 Before retry #3: sleeping 1.2 seconds 57 y u no work 58 Before retry #4: sleeping 2.4 seconds 59 y u no work 60 Before retry #5: sleeping 4.8 seconds 61 y u no work 62 Before retry #6: sleeping 9.6 seconds 63 y u no work 64 Before retry #7: sleeping 19.2 seconds 65 y u no work 66 Before retry #8: sleeping 38.4 seconds 67 y u no work 68 Before retry #9: sleeping 60.0 seconds 69 y u no work 70 Before retry #10: sleeping 60.0 seconds 71 y u no work 72 etc.. 73 74Limit retries: 75 76`retry -t 4 'echo "y u no work"; false'` 77 78 y u no work 79 Before retry #1: sleeping 0.3 seconds 80 y u no work 81 Before retry #2: sleeping 0.6 seconds 82 y u no work 83 Before retry #3: sleeping 1.2 seconds 84 y u no work 85 Before retry #4: sleeping 2.4 seconds 86 y u no work 87 Retries exhausted 88 89Bad command: 90 91`retry poop` 92 93 bash: poop: command not found 94 95Fail command: 96 97`retry -t 3 -f 'echo "oh poopsickles"' 'echo "y u no work"; false'` 98 99 y u no work 100 Before retry #1: sleeping 0.3 seconds 101 y u no work 102 Before retry #2: sleeping 0.6 seconds 103 y u no work 104 Before retry #3: sleeping 1.2 seconds 105 y u no work 106 Retries exhausted, running fail script 107 oh poopsickles 108 109Last attempt passed: 110 111`retry -t 3 -- 'if [ $RETRY_ATTEMPT -eq 3 ]; then echo Passed at attempt $RETRY_ATTEMPT; true; else echo Failed at attempt $RETRY_ATTEMPT; false; fi;'` 112 113 Failed at attempt 0 114 Before retry #1: sleeping 0.3 seconds 115 Failed at attempt 1 116 Before retry #2: sleeping 0.6 seconds 117 Failed at attempt 2 118 Before retry #3: sleeping 1.2 seconds 119 Passed at attempt 3 120 121### License 122 123Apache 2.0 - go nuts 124