Operating System - HP-UX
1753772 Members
5195 Online
108799 Solutions
New Discussion юеВ

Re: need to remove files older that 1 day

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: need to remove files older that 1 day

>what's the value I would use in -mtime to retrieve files dated 1/19

That's not what -mtime does. It uses the reference time, not midnight. If you want a date range, you must use -newer.
See these threads where there are:
( -newer temp1.touch -a ! -newer temp2.touch \)
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1254376
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1139965

>when I use +0 I get today's files 1/20

When you use +0, you get all files that have not been modified in the last 24 hours.

>when I use +1 I get nothing and I know there are file date 1/19?

When you use +1, you get all files not modified in the last 48 hours.

If you still have questions, please provide the current date & time and ll(1) on the files:
date; ll *.dbf
Yogeeraj_1
Honored Contributor

Re: need to remove files older that 1 day

hi Donald,

are you trying to purge Oracle archived redolog files?

if yes, there are much cleaner ways of managing such files. Read about RMAN and retention options.

if you need any further assistance, please let us know.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
James R. Ferguson
Acclaimed Contributor

Re: need to remove files older that 1 day

Hi (again) Donald:

> Dennis: (Assuming UNIX95=FIDDLE_WITH_FIND_TIMES isn't set.)

Agreed; Occam's razor.

> Dennis: match the file basename by using the '-name' option. Why? You think find(1) is faster than the shell? Of course if there are too many files, you are correct.

It isn't about speed, it's about whether or not he wants to descend the directory and process subdirectories, or he wants to confine himself to the top level directory.

> Dennis: Notice that I dropped the '-print' as it is superfluous and out of place. I didn't make that assumption. Perhaps Donald wanted a list? (I assumed that because it was out of place.)

I was wrong on this. I hadn't considered placing the '-print' after an '-exec', though clearly is is viable and would indeed force a listing of what was removed. I can only say that I would have written the '-exec' and its arguments as the last piece.

Regards!

...JRF...

Steve Post
Trusted Contributor

Re: need to remove files older that 1 day

There is another way to get files within a set time frame. I suprised it wasn't brought up. Perhaps there is something wrong with it I don't know about?

to find files newer than 20Jan2009 8am and older than 21Jan2009 8am
touch -t YYYYMMddHHmm ./filename

cd /u03/oradata/archive
touch -t 200901200800 ./before
touch -t 200901210800 ./after
find . \( -newer ./before -a ! -newer ./after \) -type f -name "*.dbf" -exec rm -f {} +
rm ./before
rm ./after

And that + is great. I never knew that. And I've been using find for many years. If you have an extremely large number of files to delete (astronomically big that is) I suspect it would complain about too many arguments?




TTr
Honored Contributor

Re: need to remove files older that 1 day

@ Steve: > I suprised it wasn't brought up.

Did you read Dennis' reply, 3rd reply above your reply? He does mention the newer option and 2 URL that have a lot more details on the newer and "older" options.

Donald's original question was "... files older than 1 day", It was changed later on but at this point I am not sure what he is after.not
Steve Post
Trusted Contributor

Re: need to remove files older that 1 day

yep. I didn't see that 3 replies up.

But at least I provided the syntax of the touch command. And even though the guy didn't ask it, you might be surprised how many times I got answers to questions I didn't ask (yesterday). It is most of the time. And sometimes a side step can provide a faster, simplier safer solution.

Dennis Handly
Acclaimed Contributor

Re: need to remove files older that 1 day

>Steve: I surprised it wasn't brought up.

Those were in the links I mentioned.

>If you have an extremely large number of files to delete. I suspect it would complain about too many arguments?

Yes. You could fix this as JRF said.

>But at least I provided the syntax of the touch command.

That was also in the links.
Steve Post
Trusted Contributor

Re: need to remove files older that 1 day

ok. thanks. I'll stop writing until I read all the posts and all the links.
Steve Post
Trusted Contributor

Re: need to remove files older that 1 day

....most of the time. It seems a bit silly to be denied the ability to help a person, just because I didn't read all the text and follow all the links.

Since I'll never please everyone anyhow. So I'll do what I want.... which is... in my mind... to attempt to be helpful.

Besides. My normal points for answers is: Unassigned.
Hein van den Heuvel
Honored Contributor

Re: need to remove files older that 1 day

Steve>> Besides. My normal points for answers is: Unassigned.

Confirmed :-).

Dennis>> Assuming UNIX95=FIDDLE_WITH_FIND_TIMES isn't set.

Ok, I give up. I first looked in some man pages, then I googled, searched HP.com (useless), searched the current hpux docs in pdf, even askes Jeeves. No hint on this option. Please explain!


yogeeraj> are you trying to purge Oracle archived redolog files?

That's what I was thinking.

yogeeraj>> if yes, there are much cleaner ways of managing such files. Read about RMAN and retention options.

That might be the best answer yet.


Donald, perhaps CLOSE this topic with a quick summary of what helped you best?

Hein.