Re: scripting the deletion of archivelogs

From: David Barbour <david.barbour1_at_gmail.com>
Date: Tue, 29 Jul 2008 09:51:30 -0400
Message-ID: <69eafc3f0807290651t4e1a138bl8cab5f7f48212d69@mail.gmail.com>


#!/bin/ksh -x
# Set environment variables

export ORACLE_HOME=/oracle/PR1/920_64
export ORACLE_SID=PR1
export PATH=$PATH:$ORACLE_HOME/bin

host=`hostname`
fileid=`date +%m%d%y`'_'`date +%H%M`

# First we determine how much space is being used in the archivelog destination

n=`df -g /oracle/PR1/oraarch/ |grep -v Free |awk '{print substr($4,1,length($4)-1)}'`

# Sets used percentage threshold for script execution

if (($n >= 45)) then

 `ls /oracle/PR1/oraarch/*.dbf > /usr/local/scripts/oracle/low_log.txt`  `ls /oracle/PR1/oraarch/standby_transfer/*.dbf > /usr/local/scripts/oracle/high_log.txt`

  low=`head -1 /usr/local/scripts/oracle/low_log.txt | cut -f2 -d _ | cut -f1 -d .`
  high=`tail -1 /usr/local/scripts/oracle/low_log.txt | cut -f5 -d / | cut -f2 -d _ | cut -f1 -d .`

rman<<EOJ

spool log to '/usr/local/scripts/oracle/logs/archive_$fileid.log';

connect target BLAH BLAH
connect catalog BLAH BLAH

run
{crosscheck archivelog all;}

run
{delete expired archivelog all;}
yes

configure default device type to 'SBT_TAPE'; configure device type 'SBT_TAPE' parallelism 2; configure controlfile autobackup off;
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS='ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';

show all;

run{
backup format 'archive_%d_%T_%U.arc'
archivelog from sequence = $low until sequence = $high thread = 1 delete all input;}

exit

EOJ fi

exit

On Tue, Jul 29, 2008 at 9:10 AM, Dba DBA <oracledbaquestions_at_gmail.com>wrote:

> When I delete my archive logs, it lists the ones to be deleted than wants
> me to confirm that I want to delete them. How would I write a shell script
> to log into rman and delete my archive logs to get around this prompt ?
>

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jul 29 2008 - 08:51:30 CDT

Original text of this message