Oracle 数据库删除过期归档

你说的曾经没有我的故事 提交于 2020-05-07 08:49:41
#!/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';    --> 清理一个小时前的归档日志


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!