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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Deleting old archive log files.

Re: Deleting old archive log files.

From: Joan Hsieh <joan.hsieh_at_tufts.edu>
Date: Thu, 04 Apr 2002 05:43:25 -0800
Message-ID: <F001.0043B094.20020404054325@fatcity.com>


Hi Mark,

We use xxcopy utility to do that. but here is the sample script to do this.

http://www.ultratech-llc.com/KB/?File=DelOld.TXT

Delete Files Older Than XX Days
Last Modified: 15 Aug 2001


The following batch file will step through the specified starting folder (%_at_FOLDER%) and its subfolders, and delete all files older than %_at_AGE%.

It requires the use of Windows NT4 or higher, and several utilities from the Resource Kit, such as FORFILES and ROBOCOPY v1.95 or higher.

The folder must be the shortname if entered at the command line. Longname folders should be entered directly into the batch file.

The syntax is:

        DELETEOLD.BAT folder age

Example:

        DELETEOLD D:\LOGS 25



NOTE: The version below ("C") will only work in Win2K.
      See version "D" for a version compatible with
      both NT4 and Win2K.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ECHO OFF

 rem ==============================================================
 rem === Initialize Environment Variables
 rem === Last Modified On 06 Jul 2000
 rem ==============================================================
:Variables
 SETLOCAL
 SET @FOLDER=%1& IF /I "%1"=="" SET @FOLDER=C:\TEMP
 SET @AGE=%2& IF /I "%2"=="" SET @AGE=30
 SET @LOGFILE="%_at_FOLDER%\DeleteOld.LOG"


 rem ==============================================================
 rem === Recurse Through Subfolders And Delete Old Files
 rem === Last Modified On 17 Oct 2000
 rem ==============================================================
:SetFolders
 NOW Hunting Through "%_at_FOLDER%" And Subfolders For Old Files...
>%_at_LOGFILE%

 ECHO. >>%_at_LOGFILE%
 ECHO.
 ECHO Hunting Through "%_at_FOLDER%" And Subfolders For Old Files...  ECHO.
 FOR /F "TOKENS=*" %%D IN ('FORFILES -p"%_at_FOLDER%" -d-%_at_AGE% -s -c"CMD /C ECHO @PATH\@FILE"') DO CALL :RemoveFiles %%D
 rem ==============================================================
 rem === Reset Environment Variables and Exit Batch File
 rem === Last Modified On 27 Jun 2000
 rem ==============================================================
:ExitBatch
 ENDLOCAL
 GOTO :EOF
 rem ==============================================================
 rem === SUBROUTINE: Remove Files That Are Over XX Days Old
 rem === Last Modified On 17 Oct 2000
 rem ==============================================================
:RemoveFiles
 rem %* = Current Filename
 ECHO.                   >>%_at_LOGFILE%
 ECHO -- Purging "%*"...

 ECHO -- Purging "%*"... >>%_at_LOGFILE%
 ATTRIB -R -S -H "%*"
 DEL "%*"                >>%_at_LOGFILE%

 GOTO :EOF JOan

Mark Leith wrote:

> 
> Hi All,
> 
> To save me re-inventing the wheel:
> 
> Does anybody have a batch script (that runs on NT) that deletes archive log
> files that are older than X days old? I've looked at the DEL command, but
> this doesn't have a date/time based attribute parameter..
> 
> Has anybody been through this already?
> 
> All help appreciated!
> 
> Mark
> 
> ===================================================
>  Mark Leith             | T: +44 (0)1905 330 281
>  Sales & Marketing      | F: +44 (0)870 127 5283
>  Cool Tools UK Ltd      | E: mark_at_cool-tools.co.uk
> ===================================================
>            http://www.cool-tools.co.uk
>        Maximising throughput & performance
> 
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Mark Leith
>   INET: mark_at_cool-tools.co.uk
> 
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Joan Hsieh
  INET: joan.hsieh_at_tufts.edu

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Apr 04 2002 - 07:43:25 CST

Original text of this message

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