天天看点

oracle 日志缓存清理,[oracle] 数据库日志清理脚本

vi /root/db_clearlog.sh

chmod 700 /root/db_clearlog.sh

55 6 * * * /bin/sh db_clearlog.sh

cat db_clearlog.sh

##############################################################################################

#!/bin/bash

######################################

#warning!!!!!!!!!!!!!

#please adjust values below:

#cluster_name,inst_name

######################################

cluster_name=db

inst_name=db1

db_aud_path=/u01/app/oracle/admin/${cluster_name}/adump

db_diag_path=/u01/app/oracle/diag/rdbms/${cluster_name}/${inst_name}/trace/

######################################

#aud log clear

######################################

cd /tmp/;

find ${db_aud_path} -mtime +15 -print|xargs rm -rf "*.aud";

find /u01/app/12.2.0/grid/rdbms/audit/ -mtime +15 -print|xargs rm -rf "*.aud";

######################################

#diag log clear

######################################

cd /tmp/;

find ${db_diag_path} -mtime +15 -print|xargs rm -rf "*.trm";

find ${db_diag_path} -mtime +15 -print|xargs rm -rf "*.trc";

find /u01/app/grid/diag/crs/`hostname`/crs/trace -mtime +15 -print|xargs rm -rf "*.trc";

find /u01/app/grid/diag/crs/`hostname`/crs/trace -mtime +15 -print|xargs rm -rf "*.trm";

######################################

#listen log clear

######################################

cd /tmp/;

find /u01/app/grid/diag/tnslsnr/`hostname`/listener_scan1/alert -mtime +30 -print|xargs rm -rf "*.xml";

find /u01/app/grid/diag/tnslsnr/`hostname`/asmnet1lsnr_asm/alert -mtime +30 -print|xargs rm -rf "*.xml";

find /u01/app/grid/diag/tnslsnr/`hostname`/listener/alert -mtime +30 -print|xargs rm -rf "*.xml";