Skip to content

Instantly share code, notes, and snippets.

@rjnienaber
Last active December 9, 2019 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjnienaber/835a165fc312984fbf7aa704f53762e4 to your computer and use it in GitHub Desktop.
Save rjnienaber/835a165fc312984fbf7aa704f53762e4 to your computer and use it in GitHub Desktop.
Example wait for script
#!/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