刪除DG歸檔保留5個

perfychi發表於2013-04-23
[oracle@shanxi admin]$ crontab  -l
0 20  * * *   /home/oracle/admin/del_arch.sh >>  /home/oracle/admin/del_arch.log 2>&1

[oracle@shanxi admin]$ cat /home/oracle/admin/del_arch.sh
#!/bin/bash

. /home/oracle/.bash_profile

reserve=5
max_seq=`sqlplus -s '/ as sysdba '<set linesize 200 pagesize 0  feedback off trimspool on echo off termout off time off timing off
select max(sequence#) from v\\$archived_log where name is not null;
exit;
EOF`

#echo ${max_seq}

echo "------------------------PROD-------------------------"
echo "----------------------Begin:`date`-----------------------"
hig_seq=`expr ${max_seq} - ${reserve} `
#echo $hig_seq
rman target sys/XXX@221.204.2XX.XXPROD <crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog  high sequence  ${hig_seq};
exit;
EOF
echo -e  "----------------------End:`date`-------------------------------\n"



echo -e "\n-----------------------ST---------------------------"
echo "----------------------Begin:`date`-----------------------"
rman target sys/XXX@221.204.XXX.XXX/ST <crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog high sequence ${hig_seq};
exit;
EOF
echo -e "----------------------End:`date`-------------------------------\n"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27042095/viewspace-759104/,如需轉載,請註明出處,否則將追究法律責任。

相關文章