Using find and mtime to copy files

syntax

Executive Member
Joined
May 16, 2008
Messages
8,655
cant believe i cant get this right, but anyways,

the string is this

find /example/* -mtime +90 -exec cp /var/scratch/ {} \;

basically i want to copy all files older than 90 days to /var/scratch

I suppose i could tar them first, then copy that .tar to the location, but the files are all already tar archives, and i now wanna do it this way..

any ideas?
 

syntax

Executive Member
Joined
May 16, 2008
Messages
8,655
i am tired..
correct way was
find /tests/* -mtime +480 -exec cp {} /var/scratch/ \;

*sigh*
 

syntax

Executive Member
Joined
May 16, 2008
Messages
8,655
fail...it doesnt copy the correct dated files...

/worked find /tests/* -mtime +480 -exec cp -vp {} /var/scratch/ \;

1 man thread
 

wishblade

Senior Member
Joined
Jan 14, 2009
Messages
635
couldn't piping the find results to cp work?

Might not - but just had a thought....
 

koffiejunkie

Executive Member
Joined
Aug 23, 2004
Messages
9,588
You realise that -mtime +90 will give you files that hadn't been modified for 1+90 days?

You also don't need the /* - it will find in every directory found in /example/ instead of just in example.

find /example -mtime +90 -exec cp -v {} /var/scratch/ \;
 
Top