Last active
April 10, 2019 17:33
-
-
Save vbarbarosh/a4fb38dfd5c81e45b6b3f043ff3eec65 to your computer and use it in GitHub Desktop.
shell_bash_spawn_wait – Create 100 parallel jobs and wait until they are done https://codescreens.com
This file contains hidden or 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
| #!/bin/bash | |
| # http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
| # http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
| set -o nounset -o errexit -o pipefail | |
| # https://www.percona.com/blog/2017/10/01/one-million-tables-mysql-8-0/ | |
| function long_run | |
| { | |
| echo job $1 begin | |
| sleep 5 | |
| echo job $1 end | |
| } | |
| # Create 100 parallel jobs and wait until they are done | |
| for i in {1..100}; do | |
| long_run $i & | |
| done | |
| wait | |
| echo all done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment