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

2024-05-15 17:25:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这样一个空壳脚本

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

在这个循环中,我想一起运行这样的程序,但我不希望脚本在所有程序完成处理之前传递到下一个循环。你知道吗

我怎么办?你知道吗

谢谢你


Tags: py程序脚本truegetdodonewhile
2条回答

我通常用xterm做这些

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

使用内置的wait。所以,不需要循环,甚至:

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

它将等待上述命令完成

相关问题 更多 >