#!/bin/bash
set -e
set -x
source /home/oracle/.bash_profile
ORACLE_SID=orcl
table='v$archived_log'deldir='/databak/shell'sqlplus -silent "/ as sysdba"<<EOF > ${deldir}/deleteorclarch.sh
set heading off;
set pagesize 0;
set term off;
set feedback off;
set linesize 32767;
select 'rm -rf '||name from ${table} where DELETED='NO' and APPLIED='YES' and name!='standbydb';
exit;
EOFsh ${deldir}/deleteorclarch.sh
rman target /<<END
crosscheck archivelog all;
delete noprompt expired archivelog all;
exit;
END
目前使用的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
set -e
#set -xsource /home/oracle/.bash_profile
DATE=`date +%Y%m%d%H`rman target / <<EOF
run{
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'sysdate-7';
}
exit;
EOFexit