6

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 ?

ChiseledAbs
  • 2,243
  • add & to run in background http://unix.stackexchange.com/questions/103731/run-a-command-without-making-me-wait – Kamaraj Dec 13 '16 at 07:36

1 Answers1

7

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