你确定rsyncs 真的没有并行运行吗?
在命令运行时检查ps | grep rsync
将显示哪些 rsync 以及多少个 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.
我的猜测是 rsyncs 实际上是并行运行的,但是从输出中感觉它们是串行运行的。-u
选项改变了这一点。
--
例如使用这个 cmd:
$ for i in 1 2 3 ; do echo a$i ; sleep 1 ; done
a1
a2
a3
默认情况下,在全部完成之前,我们不会收到任何反馈:
$ (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
而-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
在这两种情况下,它都需要 3 秒才能运行,所以它实际上是同时运行的......