Skip to content

Instantly share code, notes, and snippets.

@alex-kovshovik
Created October 18, 2016 13:18
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 alex-kovshovik/96e5fc8f7ee070c3b4b90d30cdb12b16 to your computer and use it in GitHub Desktop.
Save alex-kovshovik/96e5fc8f7ee070c3b4b90d30cdb12b16 to your computer and use it in GitHub Desktop.
Run parallel processes in bash
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