简体   繁体   中英

Running multiple programs together in the shell script in infinite while loop

I have such a shell script;

while true
do
     python get_proxies.py
     python run1.py & python run2.py & python run3.py & python run4.py &
     ......
done

In this loop, I want to run such programs together, but I don't want the script to pass to the next loop until all the programs finish processing.

How can I manage that?

Thanks,

Use the built in wait . So, no need for the loop even:

python run1.py & python run2.py & python run3.py & python run4.py &
wait

It will wait until the above commands complete

我通常使用xterm

xterm -e "sh -c 'python myscript.py'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM