ITPub博客

首页 > 数据库 > Oracle > 最佳实践(保持、清理ORACLE alert日志)

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

原创 Oracle 作者:hurp_oracle 时间:2015-06-23 08:56:23 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/29446986/viewspace-1708597/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: auto_unlock_stats.sh
请登录后发表评论 登录
全部评论

注册时间:2014-01-17

  • 博文量
    152
  • 访问量
    647359