-//发现自己写的清除aud脚本通用性不好,每次都要修改,写一个通用脚本.而且一些服务器有多个实例的情况.
--//编写脚本如下:
cat /usr/local/bin/purge_oracle_aud.sh
! /bin/bash
purge oracle audit log
odebug=${ODEBUG:-0}
if (( $# < 1 ))
then
echo "arguments is insufficiency , argumentN = oracle_sid N>=1"
exit 1
fi
for i in "$@"
do
if [ -d /u01/app/oracle/admin/${i}/adump/ ]
then
echo
echo "start purge oracle audit ${i} at : " $(/bin/date +‘%Y/%m/%d %T‘)
/usr/bin/find /u01/app/oracle/admin/${i}/adump/ -mtime +30 -name "${i}_ora_*.aud" -print -delete
echo "end purge oracle auditwww.cungun.com ${i} at : " $(/bin/date +‘%Y/%m/%d %T‘)
echo
else
echo "/u01/app/oracle/admin/${i}/adump/ directory is not exist"
exit 2
fi
done
chmod 700 /usr/local/bin/purge_oracle_aud.sh
--//还是通用性不好,没有利用环境变量$ORACLE_BASE,先暂时这样没时间.
2.加入crontab页游脚本:
cat /etc/cron.d/ntp
34 6 * root /usr/local/bin/purge_oracle_aud.sh dbcndg2 >> /var/log/purge_oracle_aud.log 2>&1
--//每天6:34分执行.
3.修改/etc/logrotate.d/oracle,加入如下:
grep -v "^#" /etc/logrotate.d/oracle
/var/log/purge_oracle_aud.log
{
size=20M
rotate 5
copytruncate
compress
notifempty
missingok
}
--//audit更加合理一些.