프린트 하기

OS환경 : Oracle Linux 7.2(64bit)

 

DB 환경 : Oracle Database 18.1.0.3

 

쿼리 : rmanwork.sh rman으로 아카이브 FULL 시 3일 지난것들 제거하는 쉘

rmanwork.sh 쉘 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ cat rmanwork.sh 
date >> /home/oracle/ppp/rmanwork.log
echo "start rmanwork" >> /home/oracle/ppp/rmanwork.log
 
mkdir -/oracle/app/oracle/fast_recovery_area/ORAC/oldlog/
find /oracle/app/oracle/fast_recovery_area/ORAC/archivelog/ -mtime +2 -exec mv {} /oracle/app/oracle/fast_recovery_area/ORAC/oldlog/ \;
rm -rf /oracle/app/oracle/fast_recovery_area/ORAC/oldlog/
 
rman target / << EOF1
crosscheck archivelog all;
delete expired archivelog all;
yes
exit
EOF1
 
sqlplus / as sysdba << EOF2
alter system archive log current;
EOF2
 
rman target / << EOF0
delete backup;
yes
backup database;
EOF0
 
date >> /home/oracle/ppp/rmanwork.log
echo "end rmanwork" >> /home/oracle/ppp/rmanwork.log

 

 

크론탭(crontab) 등록

1
2
$ crontab -e
0 6 * * 1,3,5 /home/oracle/ppp/rmanwork.sh

 

 

결과값 : 

크론탭 결과

1
2
3
4
5
$ cat rmanwork.log 
Mon Oct  1 17:09:38 KST 2018
start rmanwork
Mon Oct  1 17:10:35 KST 2018
end rmanwork

 

 

참조 :