Oracle归档日志定时删除任务

1、在Oracle账号下,创建归档日志删除文件del_arch.sh

文件位置:/home/oracle/crontabOra,内容如下:

#!/bin/bash
LOG_DIR=/home/oracle/crontabOra/log/
DATEL=`date '+%Y-%m-%d'`
LOG_NAME=${LOG_DIR}${DATEL}".log"

$ORACLE_HOME/bin/rman log=$LOG_NAME target sys/123456@greedb <<EOF
crosscheck archivelog all;
delete force noprompt archivelog all completed before 'sysdate-6';
exit;
EOF

2、赋可执行权限

chmod +x del_arch.sh

3、设定定时任务,在Oracle账号下,编辑配置文件

crontab -e

配置文件内容(每天下午5点执行删除任务):
0 17 * * * /home/oracle/crontabOra/del_arch.sh

ps -ef | grep crond #判断定时服务是否启动

service crond start|stop|restart #启动、停止或重启服务

原文地址:https://www.cnblogs.com/saratearing/p/6266208.html