【问题标题】:Running multiple programs together in the shell script in infinite while loop在无限while循环中在shell脚本中一起运行多个程序
【发布时间】:2016-02-28 20:22:10
【问题描述】:

我有这样一个shell脚本;

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

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

我该如何管理?

谢谢,

【问题讨论】:

    标签: python shell ubuntu


    【解决方案1】:

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

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

    它会等到上面的命令完成

    【讨论】:

      【解决方案2】:

      我通常使用 xterm 来做这些

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

      【讨论】:

        猜你喜欢
        • 2019-04-30
        • 1970-01-01
        • 2015-12-21
        • 1970-01-01
        • 2014-11-03
        • 2014-06-11
        • 2015-04-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多