Created
April 2, 2015 19:29
-
-
Save tkellen/e0f81125953b86c39038 to your computer and use it in GitHub Desktop.
poll for something and exit when good
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
POLL_INTERVAL=1 | |
TIMEOUT_COUNT=5 | |
COUNTER=1 | |
FILE="stop.txt" | |
printf "waiting for stop.txt to appear" | |
while true; do | |
if [ $COUNTER -gt $TIMEOUT_COUNT ] | |
then | |
echo "too slow" | |
exit 1 | |
fi | |
if [ -f $FILE ] | |
then | |
echo "!" | |
echo "ready" | |
exit 0 | |
else | |
printf "." | |
sleep $POLL_INTERVAL | |
COUNTER=$[$COUNTER +1] | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment