最佳实践(保持、清理ORACLE alert日志)

Please modify the script variables below to your specifics.


LOGFILE_DIR
RETENTION_DAYS
RETENTION_SIZE

RUEI has a script called clean.sh

--------------------------------
#!/bin/bash
#
# Automatically clean the Automatic Diagnostics Repository (ADR) directories.
#
source /etc/ruei.conf &>/dev/null

RETENTION_DAYS=7
RETENTION_SIZE=10M

export PATH=$PATH:/usr/local/bin # oraenv needs to find dbhome
export ORACLE_SID=$RUEI_DB_INST # oraenv looks for this name in /etc/oratab

ORAENV_ASK=NO . oraenv &>/dev/null 0>&-

[ -z "${ORACLE_BASE}" ] && exit 1
[ -z "${ORACLE_HOME}" ] && exit 1

for dir in $ORACLE_BASE/diag \
  $ORACLE_HOME/log
do
  #
  # Too big files are moved to .bak (and .bak files will be removed when
  # they become too old).
  #
  find ${dir} -type f -size +$RETENTION_SIZE '!' -name '*.bak' \
  -exec mv '{}' '{}.bak' ';'

  #
  # Too old files are removed.
  #
  find ${dir} -type f -mtime +$RETENTION_DAYS -exec rm -f '{}' ';'

done &>/dev/null

exit 0
--------------------------------

you can modify the script as follows, just replace the right directory for LOGFILE_DIR:

--------------------------------
#!/bin/bash
#


LOGFILE_DIR= /usr/lib/oracle/11.2/client64/lib/log/diag/clients/user_moniforce....
RETENTION_DAYS=7
RETENTION_SIZE=10M

export PATH=$PATH:/usr/local/bin # oraenv needs to find dbhome



for dir in $LOGFILE_DIR
do
  #
  # Too big files are moved to .bak (and .bak files will be removed when
  # they become too old).
  #
  find ${dir} -type f -size +$RETENTION_SIZE '!' -name '*.bak' \
  -exec mv '{}' '{}.bak' ';'

  #
  # Too old files are removed.
  #
  find ${dir} -type f -mtime +$RETENTION_DAYS -exec rm -f '{}' ';'

done &>/dev/null

exit 0
--------------------------------



Please put it in the cron,
type 'man crontab', then '5' for details details on the syntax for the schedule frequency,
(the syntax requires higher maths, so luckily examples are included) 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29446986/viewspace-1708597/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29446986/viewspace-1708597/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值