Skip to content

Instantly share code, notes, and snippets.

@vbarbarosh
Last active April 10, 2019 17:33
Show Gist options
  • Select an option

  • Save vbarbarosh/a4fb38dfd5c81e45b6b3f043ff3eec65 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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