This is in RHEL 5.need a ascript

This is in RHEL..need a script  which shuld find all the files older than 4 hours and move it to a different folder

find /obiee/BI/xml/ -type f  -mtime +240 -exec mv -f {} /staging/obiee2/ \;

This command above ist working
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

four hours is +mtime 4

find /obiee/BI/xml/ -type f  -mtime +4 -exec mv -f {} /staging/obiee2/ \;
Woo, sorry should be +mmin 240
find /obiee/BI/xml/ -type f  -mmin +4 -exec mv -f {} /staging/obiee2/ \;

 -mmin n       File's data was last modified n minutes ago.
my fat finger
 find /obiee/BI/xml/ -type f  -mmin +240 -exec mv -f {} /staging/obiee2/ \;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

you could also use touch -t <fourhoursago> /tmp/testfile
where <fourhoursago> has the format YYYYMMDDHHMM
find /obiee/BI/xml -type f -newer /tmp/testfile
If you have a lot of files and/or filenames with spaces in them, you should use

find /obiee/Bi/xml -type f -mmin +240 -print0 | xargs -0 -i mv -f {} /staging/obiee2

Open in new window

Pieter JordaanSenior Systems Administrator - Web hosting and Network Security.Commented:

I agree with arnold.
-newer is more reliable.

This all depends on how you want to use it.
a four hourly cronjob can touch a file to update it's last run time at the end, then when it starts again, just point -newer to it.
That way you don't miss any files.

Please explain how -newer is more "reliable".
Pieter JordaanSenior Systems Administrator - Web hosting and Network Security.Commented:

well, -newer will even use the seconds.
So if you want it to be exact, you don't want to miss files that were created in the 59 seconds leading up to the minute.

I also found differences with the output set using -newer compared -mtime or -mmin.
Perhaps a bug in the ubuntu 10 version of find.

It is just better to give it the exact time to start the search from.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.