我尝试在脚本上使用 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