Dai*_*vid 7 parallel-processing shell rsync gnu-parallel
我正在尝试rsync使用sshwith 运行一些并行实例GNU parallel.我正在运行的命令是这样的:
find /tmp/tempfolder -type f -name 'chunck.*' | sort | parallel --gnu -j 4 -v ssh -i access.pem user@server echo {}\; rsync -Havessh -auz -0 --files-from={} ./ user@server:/destination/path
Run Code Online (Sandbox Code Playgroud)
/tmp/tempfolder包含带前缀的文件,chunck它们包含实际的文件列表.
使用此命令,我得到了4个调用rsync,但是他们需要一段时间才能开始运行,并且不能一起启动并且不能并行运行.
我究竟做错了什么?
您确定rsync 真的没有并行运行吗?在命令运行时
检查将显示实际上同时运行的 rsync 数量和数量。ps | grep rsync
默认情况下,parallel保留每个作业的打印输出直到其完成,以便不同命令的输出不会全部混合在一起:
--group Group output. Output from each jobs is grouped together and is only printed when the command
is finished. stderr (standard error) first followed by stdout (standard output). This takes
some CPU time. In rare situations GNU parallel takes up lots of CPU time and if it is
acceptable that the outputs from different commands are mixed together, then disabling
grouping with -u can speedup GNU parallel by a factor of 10.
--group is the default. Can be reversed with -u.
Run Code Online (Sandbox Code Playgroud)
我的猜测是 rsync 实际上是并行运行的,但从输出来看,感觉它们是串行运行的。-u选项改变了这一点。
--
例如使用这个命令:
$ for i in 1 2 3 ; do echo a$i ; sleep 1 ; done
a1
a2
a3
Run Code Online (Sandbox Code Playgroud)
默认情况下,在全部完成之前我们不会得到并行的反馈:
$ (echo a ; echo b ; echo c ) | parallel 'for i in 1 2 3 ; do echo {}$i ; sleep 1 ; done '
a1
a2
a3
b1
b2
b3
c1
c2
c3
Run Code Online (Sandbox Code Playgroud)
而有的-u东西会立即打印出来:
$ (echo a ; echo b ; echo c ) | parallel -u 'for i in 1 2 3 ; do echo {}$i ; sleep 1 ; done '
a1
b1
c1
a2
b2
c2
a3
b3
c3
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,运行都需要 3 秒,所以它实际上是同时运行的......