#!/bin/bash
echo "----------------------------------------`date`---------------------------------------"
source ~/.bash_profile
delarchtime=`date +"20%y%m%d%H%M%S"`
RMAN_LOG_FILE=/home/oracle/del_arch_${delarchtime}.log
rman target / <<EOF >> $RMAN_LOG_FILE
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'sysdate-7';
EOF
echo -e "\n"
echo "------------------------------------ FINISHED ------------------------------------"
30 2 * * 0 /home/oracle/zzh/del_arch.sh
30 2 * * 0 nohup /home/oracle/zzh/log/delete_arch.sh >/dev/null 2>&1 &
eg:
delete noprompt archivelog until time "to_date('2019-09-02','YYYY-MM-DD')";
delete noprompt archivelog until time "to_date('2016-09-14 18:00:00','YYYY-MM-DD hh24:mi:ss')";
delete archivelog until sequence 16;
delete archivelog from time 'sysdate-1'; --> 注意这个命令,删除系统时间1天以内到现在的归档日志
delete noprompt archivelog all completed before 'sysdate'; --> 该命令清除当前所有的归档日志
delete noprompt archivelog all completed before 'sysdate-0'; --> 该命令清除当前所有的归档日志
delete noprompt archivelog all; --> 该命令清除当前所有的归档日志
delete force archivelog all completed before 'sysdate-1/24'; --> 清理一个小时前的归档日志
来源:oschina
链接:https://my.oschina.net/u/4322037/blog/4268853