I want to start multiple 10 jobs at a time and then wait for them to finish and then start 10 more jobs in parallel in background repeat this till all the 100 jobs are done.
Here is the python code that calls the shell script
from subprocess import call
# other code here.
# This variable is basically # of jobs/batch.
windowsize = 10
# Here is how I call the shell command. I have 100 jobs in total that I want as 10 batches with 10 jobs/batch.
for i in range (0..100) :
numjobs = i + windowsize
# Start 10 jobs in parallel at a time
for j in range (i..numjobs) :
call (["./myscript.sh", "/usr/share/file1.txt", ""/usr/share/file2.txt"], shell=True)
# Hoping that to wait until the 10 jobs that were recently started in background finish.
call(["wait],shell=True)
In my shell script I have this
#!/bin/sh
# I start the job in background. Each job takes few minutes to finish.
shell command $1 $2 &
...
Unfortunately, all 100 jobs are started and not 10 batches with 10 jobs/batch.