I have 2 python scripts A.py and B.py
I'd like to run both of them in parallel, but I'd like to keep running B.py multiple times successively in parallel until A.py finishes
something like :
A.py &
while A.py not finished :
B.py &
end while
I'm very bad at shell scripting, can someone explain me how to do this ?
Thank you in advance
CodePudding user response:
You can use this loop:
#!/bin/bash
python A.py &
while [[ $(jobs -pr) ]]; do
python B.py
done
jobs -pr
lists the process IDs (-p
) of running jobs (-r
). If the output is empty, the backgrounds command has finished.