GNU parallel with rsync

纵然是瞬间 提交于 2019-12-05 06:16:53

Are you sure the rsyncs are really not running in parallel ?
Checking with ps | grep rsync while the command is running will show which and how many rsyncs are actually running simultaneously.

By default, parallel holds printing output from each job until it's finished so that the different commands' output don't get all mixed up together:

--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.

My guess is the rsyncs are actually running in parallel, but from the output it feels like they're running serial. -u option changes that.

--

For example with this cmd:

$ for i in 1 2 3 ; do echo a$i ; sleep 1 ; done
a1
a2
a3

By default in parallel we get no feedback until it's all done:

$ (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

Whereas with -u stuff get printed right away:

$ (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

In both cases it took 3s to run though so it's really running simultaneously...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!