Created
October 18, 2016 13:18
-
-
Save alex-kovshovik/96e5fc8f7ee070c3b4b90d30cdb12b16 to your computer and use it in GitHub Desktop.
Run parallel processes in bash
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
rm -rf mrd.log | |
rm -rf mrd.err | |
# Anything in round braces is a subshell. By default it runs in foreground as well, | |
# but if you add "&" at the end - it would run as a sub-process. | |
( | |
echo "Waiting for mrd to start." | |
while true; do | |
sleep 1s | |
if [ ! -f mrd.log ]; then | |
continue | |
fi | |
if [[ `tail -2 mrd.log` == *"Starting MySQL server"* ]]; then | |
break | |
fi | |
done | |
echo "Waiting for 2 seconds." | |
sleep 2s | |
echo "Creating first test database." | |
mysql --socket=/Volumes/MySQLRAMDisk/mysql.sock -uroot -e "create database test_development; create database test_production;" | |
echo "Ready to rock!" | |
) & | |
mrd > mrd.log 2>mrd.err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment