Skip to content

Instantly share code, notes, and snippets.

@BlinkyStitt
Created September 19, 2012 18:13
Show Gist options
  • Save BlinkyStitt/3751224 to your computer and use it in GitHub Desktop.
Save BlinkyStitt/3751224 to your computer and use it in GitHub Desktop.
Wait for MySQL
#!/bin/bash
TIMEOUT=10
echo -n 'waiting for stop...'
i=0
while mysql -e 'show status' > /dev/null 2>&1; do
if [ $i -gt $TIMEOUT ]; then
echo 'failed!'
exit 1
fi
sleep 1
echo -n '.'
let "i++"
done
echo 'stopped!'
echo -n 'waiting for start...'
i=0
while ! mysql -e 'show status' > /dev/null 2>&1; do
if [ $i -gt $TIMEOUT ]; then
echo 'failed!'
exit 1
fi
sleep 1
echo -n '.'
let "i++"
done
echo 'started!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment