1、编辑删除归档日志的脚本----/home/oracle/clearlog.sh
#! /bin/bash
source ~/profile_orcl
#记录归档删除的日志
exec >> /home/rman_log/log/del_arch`date +%F-%H`.log
$ORACLE_HOME/bin/rman target / <<EOF
#检查归档
crosscheck archivelog all;
#列出无效的归档日志
list expired archivelog all;
#删除无效归档
delete noprompt expired archivelog all;
#删除七天前的归档
delete noprompt archivelog until time ‘sysdate-7‘;
#删除所有的归档
#delete noprompt archivelog all;
exit;
EOF
2、修改clearlog.sh脚本的权限及所有者所属组
chown oracle:oinstall clearlog.sh
chmod 775 clearlog.sh
3、以oracle用户设置定时任务
$crontab -e
* * * * * /home/oracle/clearlog.sh
原文地址:https://www.cnblogs.com/orcl-2018/p/10410996.html
时间: 2024-10-25 15:22:50