【问题标题】:gnu parallel: sync output?gnu并行:同步输出?
【发布时间】:2017-04-20 14:45:14
【问题描述】:

我正在运行这样的 gnu 并行作业:

parallel program ::: 1 2 3 4 5 6 7 8 9 10 > output.txt

我想保证输出文件是有序的。即第一行对应program 1的输出,下一行对应program 2的输出,以此类推

我如何保证这一点?

【问题讨论】:

    标签: bash parallel-processing synchronization gnu-parallel


    【解决方案1】:

    我认为-k 选项可能是您想要的:

     --keep-order
       -k       Keep sequence of output same as the order of input.
                Normally the output of a job will be printed as soon
                as the job completes.
                Try this to see the difference:
                  parallel -j4 sleep {}\; echo {} ::: 2 1 4 3
                  parallel -j4 -k sleep {}\; echo {} ::: 2 1 4 3
    

    在手册页的前一个示例中,输出为1 2 3 4,而后者确实产生了2 1 4 3

    【讨论】:

      猜你喜欢
      • 2016-03-20
      • 2022-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      相关资源
      最近更新 更多