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 #啟動、停止或重啟服務