I'm currently using the following command to copy a subset of a co-worker's logfiles over to another location for my own records and further analysis.
find . -name '*somestring*' -type f -exec cp -v --update -i {} '//anetworkdrive/logfiles/' \;
Over time, as the number of files in each location grows, this has been getting slower (obviously), but seems to be slowing down more than I'd expect.
If I run time find . -name '*somestring*' -type f
in the source and destination folders, it finds < 1,000 files in each location and that takes about 0.2s (real).
In a scenario where nothing has changed on either end since the last run, I would have thought the above copy command wouldn't take much longer than the find alone. The find
returns a list of files in < 1s, and I thought cp --update
would then check the modified date on both files (src, dest) very quickly and skip if they match.
However, my full copy command is now taking almost a full minute, making wonder if it's doing a more detailed compare than just mod date, e.g. a full diff or something.
Can someone explain to me why the above command takes so long even when nothing has changed?
And is there a faster way to do this? Would it be faster to pipe the find results to cp?
Thanks.
cp
can take multiple source definitions. You should absolutely take advantage for that. Also,rsync
.