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
aixtutorialAsked:
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.

wesly_chenCommented:
four hours is +mtime 4

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

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

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

arnoldCommented:
you could also use touch -t <fourhoursago> /tmp/testfile
where <fourhoursago> has the format YYYYMMDDHHMM
find /obiee/BI/xml -type f -newer /tmp/testfile
0
TintinCommented:
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

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

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.

0
TintinCommented:
Please explain how -newer is more "reliable".
0
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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.