简体   繁体   English

在Shell脚本中无限循环同时运行多个程序

[英]Running multiple programs together in the shell script in infinite while loop

I have such a shell script; 我有这样的shell脚本;

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 . 使用内置的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'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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