1、用oracle用户在/home/oracle/新建可执行文件del_arch.sh
vim /home/oracle/del_arch.sh
2、del_arch.sh脚本内容
#!/bin/bash
echo "----------------------------------------`date`---------------------------------------"
source ~/.bash_profile
rman target / <<EOF
crosscheck archivelog all;
delete expired archivelog all;
delete noprompt archivelog all completed before 'sysdate-3';
EOF
echo -e "\n"
echo "------------------------------------ FINISHED ------------------------------------"
3、用root用户赋权限
chmod 777 del_arch.sh
4、加入crontab定时任务(每天凌晨1点执行一次)
[oracle@localhost ~]$ crontab -e
0 1 * * * /home/oracle/del_arch.sh