aixtutorial
asked on
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
find /obiee/BI/xml/ -type f -mtime +240 -exec mv -f {} /staging/obiee2/ \;
This command above ist working
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you could also use touch -t <fourhoursago> /tmp/testfile
where <fourhoursago> has the format YYYYMMDDHHMM
find /obiee/BI/xml -type f -newer /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
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.
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".
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.
find /obiee/BI/xml/ -type f -mtime +4 -exec mv -f {} /staging/obiee2/ \;