본문 바로가기

Oracle/Admin

[Oracle]Oracle log 관리 명령어 정리

728x90

audit_file_dest
background_dump_dest
user_dump_dest

 

 

위치 확인 
select value from v$diag_info;

cd /opt/oracle/diag/rdbms/xe/XE/trace
cd /opt/oracle/diag/rdbms/xe/XE/alert

vi delete_oracle_log.sh

#!/bin/bash

# Audit Log (보관주기 6개월)
find /opt/oracle/admin/XE/adump/*.aud -mtime +180 -exec rm {} \\;

# Background & User Dump Log (보관주기 3개월)
find /opt/oracle/homes/OraDBHome21c/XE/rdbms/log/*.trc -mtime +90 -exec rm {} \\;

# Alert Log (보관주기 3개월)
find /opt/oracle/diag/rdbms/xe/XE/alert/*.xml -mtime +90 -exec rm {} \\;

# Trace Log (보관주기 3개월)
find /opt/oracle/diag/rdbms/xe/XE/trace/*.trc -mtime +90 -exec rm {} \\;
find /opt/oracle/diag/rdbms/xe/XE/trace/*.trm -mtime +90 -exec rm {} \\;



chmod 755 delete_oracle_log.sh


crontab -e
## Oracle Log Delete
01 0 1 * * /delete_oracle_log 만든 경로/delete_oracle_log.sh
crontab -l



분 시 일(*:매일, 5:5일) 달(*:매달, 5:5월) 요일(0은 일요일, 6은 토요일)
0 5 * * * : 매일 5시 0분에 실행.
5 * * * * : 매시 5분이 될 때마다 실행. 즉, 한 시간 간격으로 실행.
* * * * * : 1분에 한 번씩 실행.
0 5 1 * * : 매달 1일 새벽 5시에 실행.

*/5 * * * * : 5분마다 한 번씩
0 */5 * * * : 5시간마다 한 번씩

0 5,11 * * * : 새벽 5시와 밤 11시.
0 5,11 * * 0,3 : 매주 일요일과 수요일 새벽 5시와 밤 11시.


vi delete_listener_log.sh
ls -lh

#!/bin/bash
export ORACLE_SID=XE
export ORACLE_HOME=/opt/oracle/homes/OraDBHome21c/XE
export PATH=$ORACLE_HOME/bin:$PATH
export DATE=`date -d '1 month ago' +%Y%m` 

cd /opt/oracle/diag/rdbms/xe/XE/trace

cp listener.log listener.log_${DATE}
zip listener.log_${DATE}.zip listener.log_${DATE}

cat /dev/null > /opt/oracle/diag/rdbms/xe/XE/trace/listener.log
rm -rf /opt/oracle/diag/rdbms/xe/XE/trace/listener.log_${DATE}

chmod 755 delete_listener_log.sh

crontab -e
## Listener Backup & Delete
01 0 1 * * /home/oracle/scripts/delete_listener_log.sh
crontab -l
728x90
반응형

'Oracle > Admin' 카테고리의 다른 글

[Oracle] Oracle Dump  (0) 2024.05.09
[Oracle ] Enq: TX - allocate ITL entry  (0) 2024.05.09
[Oracle] v$sysstat, v$sesstat  (0) 2024.03.22
[Oracle] ROWDEPENDENCIES , ROW_ROWSCN  (0) 2024.03.08
[Oracle]Index fragmentation  (0) 2024.02.20