我嘗試在腳本上使用 GNU 並行,我注意到它只在 -jX X jobs 之後開始輸出
# Only spawns cat after 100 seconds
(echo a; sleep 100) | parallel -j1 --lb cat
# Starts instantly
(echo a; echo a; sleep 100) | parallel -j1 --lb cat
第一個作業需要在其他作業之前啟動(因為它會將其他作業定義為並行管道,將輸出傳輸到另一個腳本),但並行正在等待另外 3 個作業
有沒有辦法改變這種模式?
答案1
升級到20181222或更高版本。
# Spawns a instantly
(echo a; sleep 100) | parallel -j1 --lb cat
# Starts a and b instantly, outputs a immediately, b after 100 sec
(echo a; echo b; sleep 100) | parallel -j1 --lb cat
# Starts a and b instantly, outputs a and b immediately (but output may be mixed)
(echo a; echo b; sleep 100) | parallel -j1 --lb cat