Last active
December 9, 2019 10:50
-
-
Save rjnienaber/835a165fc312984fbf7aa704f53762e4 to your computer and use it in GitHub Desktop.
Example wait for script
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
#!/usr/bin/env bash | |
STOP_TIME=`date -d "now + 30 seconds" +%s` | |
# loop until we get a connection | |
until nc -z localhost 3306 | |
do | |
# if current time is > STOP_TIME, timeout has been exceeded so exit | |
if [[ `date +%s` -gt $STOP_TIME ]]; then | |
echo Timed out waiting for connection | |
exit 1 | |
fi | |
sleep 1 | |
done | |
echo Successfully connected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment