Run parallel multiple commands at once in the same terminal

前端 未结 6 800
礼貌的吻别
礼貌的吻别 2020-11-28 19:15

I want to run a few commands, each of which doesn\'t quit until Ctrl-C is pressed. Is there something I can run to run all of them at once, and Ctrl-C will quit them all? Th

6条回答
  •  天涯浪人
    2020-11-28 19:41

    Use GNU Parallel:

    (echo command1; echo command2) | parallel
    parallel ::: command1 command2
    

    To kill:

    parallel ::: command1 command2 &
    PID=$!
    kill -TERM $PID
    kill -TERM $PID
    

提交回复
热议问题