我试图使用使用xargs创建/提取作业的并行管道复制一个非常大的文件系统。我似乎找不出正确的语法。
find image -maxdepth 2 -mindepth 2 -type d -print|xargs -P 48 tar cf - --files-from|(cd /testfiles; tar xf -)我知道这些错误:
焦油:终止于信号13 焦油:终止于信号13
但是,如果我在没有-P选项的情况下执行相同的命令,它将运行。它只是单线程,将永远地在700 K子目录中执行5000万个文件。
下面的方法很有效,但是很慢:
find image -maxdepth 2 -mindepth 2 -type d -print|xargs tar cf - --files-from|(cd /testfiles; tar xf -)那我错过了什么?
发布于 2018-05-04 23:01:45
问题是您的并行管道标准输出被来自|(cd /testfiles; tar xf -)的“单一”标准输入所消耗。
因此,您需要将tar xf -部件“也”并行化,一个可能的解决方案是将该管道视为一个“小脚本”,然后将xargs与$@传递参数。
find image -maxdepth 2 -mindepth 2 -type d -print| \
xargs -P 48 sh -c 'tar cf - --files-from $@ | tar -C /testfiles -xf -' -- 顺便说一句,我也会小心对待-P 48,从更节俭的值开始,直到您找到上述I/O影响的舒适权衡。
发布于 2021-04-18 15:34:20
在-n 1中使用xargs将使tar与前面的find命令中的每个输出行一起运行。
find image -maxdepth 2 -mindepth 2 -type d -print|xargs -n 1 -P 48 tar cf - --files-from|(cd /testfiles; tar xf -)https://stackoverflow.com/questions/50177688
复制相似问题