Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start multiple processes in Bash

Tags:

bash

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.

like image 215
igorgue Avatar asked Mar 08 '11 20:03

igorgue


People also ask

How do I run multiple scripts in bash?

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.

How run multiple processes in Linux?

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.


1 Answers

echo "Spawning 100 processes" for i in {1..100} ; do     ( ./my_script & ) ; done 
like image 137
datenwolf Avatar answered Sep 21 '22 18:09

datenwolf