2017-04-20 69 views
1

我運行一個GNU並行作業是這樣的:gnu parallel:同步輸出?

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

我要保證輸出文件是有序的。也就是說,第一行對應於program 1的輸出,輸出的下一行program 2等。

如何保證這一點?

回答

2

我認爲-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