HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

Faster way to move old file

 
heaman1
Regular Advisor

Faster way to move old file

I have thousands files in a path , I tried to use command "find" to move the old file (elder than 150 days) to another path , but it takes 1 day but only move 15% of these files , and the server also become very slow .


the command

find . -mtime +150 -exec mv {} path \;

2 REPLIES
V. Nyga
Honored Contributor

Re: Faster way to move old file

Hi,

'+' should be faster than ';'

find . -mtime +150 -exec mv {} path \+

HTH
Volkmar
*** Say 'Thanks' with Kudos ***

Re: Faster way to move old file

>Volkmar: find . -mtime +150 -exec mv {} path +

Unfortunately you can't use {} anywhere but last with "+".

So either you need to do xargs or write your own mv script that swaps the order. Unfortunately xargs -i is just as slow:
find . -mtime +150 | xargs -i echo mv {} path

So you need to use:
find . -mtime +150 -exec mv_em path {} +

mv_em:
#!/usr/bin/ksh
target=$1
shift
mv "$@" "$target"