http://www.orsweb.com/

( http://www.orsweb.com/master-list/ )

-

http://www.orsweb.com/downloads/source/418.html


rem Script Description:  This script deletes the old archivelog files that 
rem                      fill up disk space. The old archivelogs are deleted 
automatically
rem                      once a week. This script contains a stored procedure script, 
rem                      the command to submit a batch job, and the AT scheduler 
command.
rem                      It is designed to work with Windows NT and Oracle 7.x. 
rem                      Modifications need to be to the Stored Procedure to make it 
run 
rem                      under Oracle8. 
rem
rem                      This procedure creates a command file in C:\DBBACKUPS called
rem                      'archlog_del.cmd' which can be scheduled to execute by using 
the
rem                      AT command in Windows NT.  The procedure is submitted as
rem                      a batch job which is scheduled once a week and deletes old 
rem                      archives.
rem
rem                     Oracle8 Implementation -
rem                     The following changes are necessary:
rem
rem                     check trunc(time) < trunc(sysdate)-10, where time is in the 
DATE  
rem                     field and the table name is V$ARCHIVED_LOG.  In version 7.x, 
rem                     time is VARCHAR2. The procedure uses a pre-defined package 
rem                     called UTL_FILE. The init.ora should be modified to include 
rem                     a parameter called UTL_FILE_DIR=C:\DBBACKUPS so that it can 
rem                     write in that destination directory.
rem
rem
rem Prepared By:        Oracle Resource Stop
rem
rem Usage Information:  See Below
rem

CREATE OR REPLACE PROCEDURE archive_delete AS
archive_name UTL_FILE.FILE_TYPE;
archive_file varchar2(100); BEGIN 
DECLARE CURSOR c1 IS
SELECT 'del '||name name
      FROM   V_$ARCHIVED_LOG
      WHERE  trunc(COMPLETION_TIME) < trunc(sysdate)-10
      AND    trunc(COMPLETION_TIME) >=trunc(sysdate)-20; 

BEGIN 
archive_name := UTL_FILE.FOPEN('C:\DBBACKUPS','archlog_del.cmd','w'); 

FOR rec IN c1
LOOP
archive_file := rec.name;
UTL_FILE.PUT_LINE(archive_name,archive_file);
END LOOP; 
UTL_FILE.FCLOSE(archive_name); 
END; 
END; 
/ 
*****************************************************************************************
Rem  The following DBMS package procedure submits the batch job to execute
Rem  the above procedure once every week.  The job is submitted by connecting
Rem  as internal through the Server Manager.  The job executes the procedure
Rem  at 2:00 a.m. on the day you submit the job and 2:00 a.m. at the interval of 
Rem  seven days.
********************************************************************************************
SVRMGR> VARIABLE jobno number;
SVRMGR> begin
     2>    EXECUTE DBMS_JOB.SUBMIT(:jobno,
     3>             'archive_delete;',trunc(sysdate)+2/24,'(trunc(sysdate+2/24)+7');
     4> end;
     5> /
***************************************************************************************
Rem  The following AT command executes C:\DBBACKUPS\archlog_del.cmd every 
Rem  Monday Morning at 3:00 a.m and creates a log file at C:\DBBACKUPS\arch_delete.log.
****************************************************************************************
F:> at 03:00 /every:M "C:\DBBACKUPS\archlog_del.cmd 1>C:\DBBACKUPS\arch_delete.log 
2>&1" 




----------------------------------------------------

more:

http://www.google.com/search?hl=en&q=script+delete+old+files+nt


(several solutions shown at the above require Perl or VB)


In case someone else hasn't mentioned it:

(for Robocopy, you need the M$ Re$ource Kit)

http://www.win2000mag.com/Files/7045/7045.zip

:: LISTING 2: Script to Delete Old Files

@ECHO OFF
@title MOVING FILES OLDER THAN 120 DAYS...

GOTO :NEXT
:: You can use the Net Use commands to run this script
:: with the scheduler/WINAT service:
:: net use \\Your_Server \IPC$ "" /User:""
:: net use \\Your_Server \IPC$ Password /User:Domain\Username
:NEXT

SETLOCAL
:: Get date for use in filename.
for /F "tokens=1,2,3 delims=/ " %%i in ('date /T') do set date1=%%j-%%k

:: Clear old files and empty directories for Robocopy file move operation.
del /f /q /s D:\OldFiles\*.*
rmdir /q /q D:\OldFiles

:: Robocopy the files.
Robocopy.exe D:\AllFiles D:\OldFiles /minage:120 /sec /mov /s /np /eta /r:1 /w:1 
/log:D:\DeletionLogs\%date1%_robo_log.txt

ENDLOCAL
CLS
EXIT


http://www.win2000mag.com/Articles/Index.cfm?ArticleID=7045

...

Q: How can I create an NT shell script that deletes files with a date older than 
MMDDYY from a directory?

To delete files by date, you need to install the Microsoft Windows NT Server 4.0 
Resource Kit's Robocopy utility. 
Robocopy has a switch that lets you specify whether you want to copy or move files 
that are older than a certain 
age. You then take these steps:

Set up a directory in which to put the old files that you want to delete. Name the 
directory OldFiles or a 
similar intuitive name. Robocopy will move users' old files into this OldFiles 
destination folder. 
Write a script that first deletes all the files and folders in the OldFiles folder and 
then calls Robocopy. 
Listing 2 contains a script that you can adapt. In your script, have Robocopy move all 
the files that are older 
than a specified number of days (e.g., 120 days) or a specified date (e.g., 070199) 
from the source directory to 
the OldFiles folder. Robocopy automatically clears the source area of any old files, 
and you can use the /move 
switch instead of the /mov switch to clear any empty directories. 
Schedule the script to run at a specified interval with the Net Use command.

Keeping users' old files in the OldFiles folder until the next scheduled deletion run 
rather than immediately 
deleting them can save you work down the road. If users need a file that Robocopy 
removed, you can restore the 
file from the OldFiles folder rather than from the backup tape.

---end---


ORACLE-L Digest -- Volume 2002, Number 095
>  --- Mark Leith <[EMAIL PROTECTED]> 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?
> 


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Eric D. Pierce
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to