What's the best way to perform a parallel copy on Unix?

dsg

I routinely have to copy the contents of a folder on a network file system to my local computer. There are many files (1000s) on the remote folder that are all relatively small but due to network overhead a regular copy cp remote_folder/* ~/local_folder/ takes a very long time (10 mins).

I believe it's because the files are being copied sequentially – each file waits until the previous is finished before the copy begins.

What's the simplest way to increase the speed of this copy? (I assume it is to perform the copy in parallel.)

Zipping the files before copying will not necessarily speed things up because they may be all saved on different disks on different servers.

OldWolf

As long as you limit the copy commands you're running you could probably use a script like the one posted by Scrutinizer

SOURCEDIR="$1"
TARGETDIR="$2"
MAX_PARALLEL=4
nroffiles=$(ls "$SOURCEDIR" | wc -w)
setsize=$(( nroffiles/MAX_PARALLEL + 1 ))
ls -1 "$SOURCEDIR"/* | xargs -n "$setsize" | while read workset; do
  cp -p "$workset" "$TARGETDIR" &
done
wait

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

What is the current best way to wrap console.log() that will preserve line numbers?

来自分类Dev

Adding custom properties to Express app and req. What's the best way?

来自分类Dev

What's the Pythonic way to report nonfatal errors in a parser?

来自分类Dev

What is the best way to call async methods using reactiveui + throttle

来自分类Dev

What's the best way to store Phone number in Django models

来自分类Dev

What is the best way to store very large binary numbers in JavaScript?

来自分类Dev

What is the best way to iterate an nested object in rails

来自分类Dev

Best way to correct bundle ID

来自分类Dev

What is the best way to communicate between two windows in Qt

来自分类Dev

libGDX What's the best way to render a large background image?

来自分类Dev

What's the right way to use Akavache's LoadImageFromUrl in a Windows Phone project?

来自分类Dev

Best way for SqlConnection inside a loop

来自分类Dev

What's best practice when deleting unneccessary includes?

来自分类Dev

What is the best way to decouple a caller of spawn from the spawned procedure?

来自分类Dev

What's the best way to handle Culture in a .NET MVC/WebApi app which uses async?

来自分类Dev

What is the best way to parse binary protocols with Rust

来自分类Dev

Best way to perform Update call when input field value is changed in Meteor JS?

来自分类Dev

What's the best way to do math with CGFloats in swift?

来自分类Dev

What is the best way for a class to listen to events in an object it has instantiated? (Swift)

来自分类Dev

What's the best way to capture a digital signature in Rails 4?

来自分类Dev

What is the best way to map the JSON Object from a JDBC result set in vert.x to a Java/Groovy class(es)?

来自分类Dev

What's a fast (non-loop) way to apply a dict to a ndarray (meaning use elements as keys and replace with values)

来自分类Dev

What is the best way to wait for the completion of all workers in a thread pool?

来自分类Dev

What is the best way to wait for an animation to finish in MVVM?

来自分类Dev

What's the most efficient way to calculate a running total/balance when using pagination (PHP, MySQL)

来自分类Dev

Best way to get nearby entities

来自分类Dev

Is there a way to copy text in htop?

来自分类Dev

what's the windows equivalent of Unix `**`

来自分类Dev

What is the best way to coordinate the interaction of two restful services using a third one?

Related 相关文章

  1. 1

    What is the current best way to wrap console.log() that will preserve line numbers?

  2. 2

    Adding custom properties to Express app and req. What's the best way?

  3. 3

    What's the Pythonic way to report nonfatal errors in a parser?

  4. 4

    What is the best way to call async methods using reactiveui + throttle

  5. 5

    What's the best way to store Phone number in Django models

  6. 6

    What is the best way to store very large binary numbers in JavaScript?

  7. 7

    What is the best way to iterate an nested object in rails

  8. 8

    Best way to correct bundle ID

  9. 9

    What is the best way to communicate between two windows in Qt

  10. 10

    libGDX What's the best way to render a large background image?

  11. 11

    What's the right way to use Akavache's LoadImageFromUrl in a Windows Phone project?

  12. 12

    Best way for SqlConnection inside a loop

  13. 13

    What's best practice when deleting unneccessary includes?

  14. 14

    What is the best way to decouple a caller of spawn from the spawned procedure?

  15. 15

    What's the best way to handle Culture in a .NET MVC/WebApi app which uses async?

  16. 16

    What is the best way to parse binary protocols with Rust

  17. 17

    Best way to perform Update call when input field value is changed in Meteor JS?

  18. 18

    What's the best way to do math with CGFloats in swift?

  19. 19

    What is the best way for a class to listen to events in an object it has instantiated? (Swift)

  20. 20

    What's the best way to capture a digital signature in Rails 4?

  21. 21

    What is the best way to map the JSON Object from a JDBC result set in vert.x to a Java/Groovy class(es)?

  22. 22

    What's a fast (non-loop) way to apply a dict to a ndarray (meaning use elements as keys and replace with values)

  23. 23

    What is the best way to wait for the completion of all workers in a thread pool?

  24. 24

    What is the best way to wait for an animation to finish in MVVM?

  25. 25

    What's the most efficient way to calculate a running total/balance when using pagination (PHP, MySQL)

  26. 26

    Best way to get nearby entities

  27. 27

    Is there a way to copy text in htop?

  28. 28

    what's the windows equivalent of Unix `**`

  29. 29

    What is the best way to coordinate the interaction of two restful services using a third one?

热门标签

归档