1845858 Members
3876 Online
110250 Solutions
New Discussion

Re: time stamp script

 
SOLVED
Go to solution
michael_210
Advisor

time stamp script

Does anyone have a script that will find files
that are more than 1 hour old and move them to another filesystem????

or how to script it..

thansk
mike
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: time stamp script

Mike,

First create a reference file:

touch ref_file -t [[CC]YY]MMDDhhmm[.SS]

Then use the find command:

find /dirname ! -newer ref_file


At least, I think that will work for you.



Pete


Pete
Helen French
Honored Contributor
Solution

Re: time stamp script

You can do it with find command and place the script in a cron job to run it every hour:

# touch test_file

In the script:
find dir_name -newer test_file -depth | cpio -plmv /destination_dir
touch test_file

Place this script in crontab. When you run the first time, run it after an hour you created test_file. You can replace the cpio command with mv or cp.
Life is a promise, fulfill it!
Helen French
Honored Contributor

Re: time stamp script

typo .. add option 'd' with cpio:

cpio -pdmv /dest_dir
Life is a promise, fulfill it!
michael_210
Advisor

Re: time stamp script

That did the trick!! Combined Petes and shiju's responses.
thanks!!

(points assigned)
mike