【问题标题】:How to run multiple commands at the same time in bash instead of running one after another?如何在bash中同时运行多个命令而不是一个接一个地运行?
【发布时间】:2016-01-11 12:58:30
【问题描述】:

我需要在 bash 中运行多个命令,而无需等待完成第一个命令并启动其他命令。 bash 文件中的命令可以是这样的。

#!/bin/bash
perl test.pl -i file1 -o out1
perl test.pl -i file2 -o out2
and so on

所有这些都应该在不同的内核中同时运行,而不是一个接一个地运行。

【问题讨论】:

标签: bash command


【解决方案1】:

&为背景:

#!/bin/bash
perl test.pl -i file1 -o out1 &
perl test.pl -i file2 -o out2 &

或者更好的是,使用GNU parallel。这将允许您使用多个 CPU 等等。

【讨论】:

    猜你喜欢
    • 2021-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 2013-01-14
    相关资源
    最近更新 更多