设置定时任务清理归档日志
[oracle@test arch]$ crontab -l
30 1,7,13,19 * * * /home/oracle/scripts/del_arch.sh > /dev/null 2>&1
[oracle@nccdb arch]$
[oracle@test arch]$ cat /home/oracle/scripts/del_arch.sh
#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/db_1
export ORACLE_SID=ncc
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
$ORACLE_HOME/bin/rman target / log=/home/oracle/scripts/del_arch_${ORACLE_SID}_`date '+%Y%m%d%H%M'`.log <<EOF
run {
ALLOCATE CHANNEL d1 DEVICE TYPE disk;
ALLOCATE CHANNEL d2 DEVICE TYPE disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'sysdate-10';
release channel d1;
release channel d2;
}
exit;
EOF
find /home/oracle/scripts -name "del_arch_*.log" -mtime +20 |xargs rm -f {} \;
[oracle@test arch]$




