[oracle@shanxi admin]$ crontab -l
0 20 * * * /home/oracle/admin/del_arch.sh >> /home/oracle/admin/del_arch.log 2>&1
[oracle@shanxi admin]$ cat /home/oracle/admin/del_arch.sh
#!/bin/bash
. /home/oracle/.bash_profile
reserve=5
max_seq=`sqlplus -s '/ as sysdba '<
set linesize 200 pagesize 0 feedback off trimspool on echo off termout off time off timing off
select max(sequence#) from v\\$archived_log where name is not null;
exit;
EOF`
#echo ${max_seq}
echo "------------------------PROD-------------------------"
echo "----------------------Begin:`date`-----------------------"
hig_seq=`expr ${max_seq} - ${reserve} `
#echo $hig_seq
rman target sys/XXX@221.204.2XX.XXPROD <crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog high sequence ${hig_seq};
exit;
EOF
echo -e "----------------------End:`date`-------------------------------\n"
echo -e "\n-----------------------ST---------------------------"
echo "----------------------Begin:`date`-----------------------"
rman target sys/XXX@221.204.XXX.XXX/ST <crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog high sequence ${hig_seq};
exit;
EOF
echo -e "----------------------End:`date`-------------------------------\n"
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27042095/viewspace-759104/
,如需转载,请注明出处,否则将追究法律责任。