Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to purge the files that are older than 90 days

Re: how to purge the files that are older than 90 days

From: HansF <Fuzzy.Greybeard_at_gmail.com>
Date: Thu, 07 Sep 2006 22:28:18 GMT
Message-Id: <pan.2006.09.07.22.28.26.911709@gmail.com>


On Thu, 07 Sep 2006 14:17:40 -0700, joel garry wrote:

>
> HansF wrote:

>> ...
>>     man find
>>
>> to get the details - start with the following pattern:
>>
>>   find /dir -mtime 90 -a -type f -exec rm {} \;
>>
>> and test, test, test.

>
> Actually, with such a dangerous command, you probably do want to run it

Hence the suggestion to 'test, test, test'

> in a script, with ls -l instead of rm first, then a "sure delete
> these?" question (or at least output to a file if for a cron). For
> example, a cron to remove old arcs:
>
> 49 03 * * * find /noimnotgoingtoshowmyrealdirectory/arch -type f -mtime
> +2 -exec ll {} \; >> /home2/oracle/archfilerm ; find
> /noimnotgoingtoshowmyrealdirectory/arch -type f -mtime +2 -exec rm {}
> \;
>
> I've noticed the various times that find finds don't work exactly as
> documented on some systems. Your command doesn't find any files on my
> hp-ux system, for example. Though +90 does, because 90 means exactly
> 90 and +90 means greater than 90. I suppose you did that on purpose to
> make this a learning experience? :-)

And hence the '*start with* the following ...'. Yes, I had intended it to be a learning experience.

In fact, if the OP had used root to run the command as stated, and fixed the /dir to a working directory (choosing / by default as is often the case with noobs taking commands without thinking), the '90' instead of '+90' *might* have saved his system.

On second think, I'd probably change it slightly to

"exec echo rm -i {} \; > ~/rmscript"

which leaves with a rmscript to be run interactively.

-- 
Hans Forbrich   (mailto: Fuzzy.GreyBeard_at_gmail.com)   
*** Feel free to correct me when I'm wrong!
*** Top posting [replies] guarantees I won't respond.
Received on Thu Sep 07 2006 - 17:28:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US