I want to start 100 processes in bash
, but the for
statement doesn't seems to like the &
symbol and I'm getting a syntax error, here is what I have so far:
echo "Spawning 100 processes" for i in {1..100} do ./my_script.py & done
EDIT: I was copypasting this code, that's why the &
char was illegal.
The Operators &&, ||, and ; The first logical operator we will be looking at will be the AND operator: &&. In Bash, it is used to chain commands together. It can also be used to run two different scripts together.
In case you need to execute several processes in batches, or in chunks, you can use the shell builtin command called "wait". See below. The first three commands wget commands will be executed in parallel. "wait" will make the script wait till those 3 gets finished.
echo "Spawning 100 processes" for i in {1..100} ; do ( ./my_script & ) ; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With