Годная заготовка для своего скрипта: http://andrewfraserdba.com/2010/02/26/shell-script-to-clean-old-oracle-trace-and-log-files/
Желание прибивать alert_*.log странное.
#! /bin/bash
# Remove old oracle-owned aud, trc, trw, core files
# Remove old recv error files (these have format ".err_[0-9]")
# Remove access_log., error_log., emoms.log. files - which are generated in large numbers
echo "*** REMOVE OLD ORACLE AUDIT FILES and OLD RECV Error Files and OLD TRACE FILES ***"
ORABASE='/u0/apps/oracle/'
FILELIST=`/usr/bin/find $ORABASE \
-mtime +1 -user oracle \( \
-name *.aud -o\
-name '*.trw' -o \
-name '*.err_[0-9]*' -o \
-name 'access_log.[0-9]*' -o \
-name 'error_log.[0-9]*' -o \
-name 'emoms.log.[0-9]*' \) \
`
for file in $FILELIST ;
do
echo "Remove olds trash file: $file"
rm $file;
done
FILELISTTR=`/usr/bin/find $ORABASE \
-mtime +31 -user oracle \
-name '*.trc*'`
for file in $FILELISTTR ;
do
echo "Remove TRACE file: $file"
rm $file;
done
# Cut down alert logs and listener logs, and also access_log and event_log
# Old log files are ignored - only log files modified in the last 7 days are worked on.
# Small log files are ignored - only files bigger than 3mb (=6144*512 byte blocks) are worked on.
# 3mb is approximately 30,000 lines of text.
echo "*** CUT DOWN THE ALERT LOGS and ORACLE LISTENER.LOG FILE ***"
FILELISTLOG=`find $ORABASE \
-mtime -7 -size +6144 -user oracle \( \
-name 'listener*.log' -o \
-name 'access_log' -o \
-name 'event_log' -o \
-name 'http-web-access.log' -o \
-name 'server.log' \)`
for file in $FILELISTLOG
do
echo -n "*** cutting $file ***"
cp $file $file.tmp
tail -10000 $file.tmp > $file
rm $file.tmp;
done
# Rotate alert log when files size bigger than 3mb (=6144*512 byte blocks)
echo "*** ROTATE ALERT LOGS ***"
date=`date '+%Y%m%d'`
FILELISTLOG=`find $ORABASE -size +6144 -user oracle -name 'alert_*.log'`
for file in $FILELISTLOG
do
name=`echo $file | cut -d'.' -f1`
echo "*** rotate $file to $name.$date.log ***"
echo mv $file $name"."$date".log"
echo gzip -9 $name"."$date".log";
done
Желание прибивать alert_*.log странное.
#! /bin/bash
# Remove old oracle-owned aud, trc, trw, core files
# Remove old recv error files (these have format ".err_[0-9]")
# Remove access_log.
echo "*** REMOVE OLD ORACLE AUDIT FILES and OLD RECV Error Files and OLD TRACE FILES ***"
ORABASE='/u0/apps/oracle/'
FILELIST=`/usr/bin/find $ORABASE \
-mtime +1 -user oracle \( \
-name *.aud -o\
-name '*.trw' -o \
-name '*.err_[0-9]*' -o \
-name 'access_log.[0-9]*' -o \
-name 'error_log.[0-9]*' -o \
-name 'emoms.log.[0-9]*' \) \
`
for file in $FILELIST ;
do
echo "Remove olds trash file: $file"
rm $file;
done
FILELISTTR=`/usr/bin/find $ORABASE \
-mtime +31 -user oracle \
-name '*.trc*'`
for file in $FILELISTTR ;
do
echo "Remove TRACE file: $file"
rm $file;
done
# Cut down alert logs and listener logs, and also access_log and event_log
# Old log files are ignored - only log files modified in the last 7 days are worked on.
# Small log files are ignored - only files bigger than 3mb (=6144*512 byte blocks) are worked on.
# 3mb is approximately 30,000 lines of text.
echo "*** CUT DOWN THE ALERT LOGS and ORACLE LISTENER.LOG FILE ***"
FILELISTLOG=`find $ORABASE \
-mtime -7 -size +6144 -user oracle \( \
-name 'listener*.log' -o \
-name 'access_log' -o \
-name 'event_log' -o \
-name 'http-web-access.log' -o \
-name 'server.log' \)`
for file in $FILELISTLOG
do
echo -n "*** cutting $file ***"
cp $file $file.tmp
tail -10000 $file.tmp > $file
rm $file.tmp;
done
# Rotate alert log when files size bigger than 3mb (=6144*512 byte blocks)
echo "*** ROTATE ALERT LOGS ***"
date=`date '+%Y%m%d'`
FILELISTLOG=`find $ORABASE -size +6144 -user oracle -name 'alert_*.log'`
for file in $FILELISTLOG
do
name=`echo $file | cut -d'.' -f1`
echo "*** rotate $file to $name.$date.log ***"
echo mv $file $name"."$date".log"
echo gzip -9 $name"."$date".log";
done
Комментариев нет:
Отправить комментарий