Skip to content

Commit

Permalink
Add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
za3k committed Jun 1, 2015
1 parent 3b7cf66 commit 362117a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ Checks which Arch Linux package owns a command
ping-test
---
Return true if the internet is up (a single ping to 8.8.8.8 returns).

retry
---
retry a command 5 times or until it succeeds
15 changes: 15 additions & 0 deletions retry
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
nTrys=0
maxTrys=5
status=256
until [ $status == 0 ] ; do
$1
status=$?
nTrys=$(($nTrys + 1))
if [ $nTrys -gt $maxTrys ] ; then
exit $status
fi
if [ $status != 0 ] ; then
sleep 1
fi
done

0 comments on commit 362117a

Please sign in to comment.