2

I'm looking to run multiple instances of a python script with each instance being fed an incremental argument. So the bash script would do something like that :

for i from 1 to 10 do
    python script.py i

All scripts should run at the same time from one console of course. Any idea how to do that ?

3

To simply run the program ten times, with the (incremented) iteration number as an argument, do this:

for ((i=1; i<=10; i++))
do
    python script.py "$i"
done

As Kamaraj says, to get the ten processes to run at the same time (i.e., simultaneously / concurrently), add & to the command:

for ((i=1; i<=10; i++))
do
    python script.py "$i" &
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.