Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Archive Logs Growing to Fast
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C0542F.93CA0DA4
Content-Type: text/plain
Hi Larry
Here are couple examples
<<cleandir.sh>> <<dbarccln.sh>>
With regards
Alex Afanassiev
Oracle DBA, TOC OPS/Internet.Operations
Tel: (03) 8 661 20 61 Fax: (03) 9 650 36 74>
> -----Original Message-----
> From: Larry Taylor [SMTP:ltaylor_at_iq.com]
> Sent: Wednesday, November 22, 2000 12:18 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Archive Logs Growing to Fast
------_=_NextPart_000_01C0542F.93CA0DA4
Content-Type: application/octet-stream;
name="cleandir.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="cleandir.sh"
#! /bin/ksh # name cleandir.sh =20 # # ****** ATT!!! ***** # This scipt deletes files from the directory passed in =09 # as a parameter # # purpose this script finds the files that has not been accessed # more than N days and removes them # # usage cleandir.sh <dir> <days>=20 # # parameters $1=3Ddirectory to check (mandatory) # $2=3Dretention period in days (optional, defalted to 14) # # .............................................................. # return code
# # booleans #
# validate parameters # # job name=20
CHECKDIR=3D$1
else=20
echo $ERRMSG
exit ${ERROR}
fi
if [ "$2" ]; then=20
RTIME=3D$2
else
RTIME=3D14
fi
# add 3 days cool off period #if [ $RTIME -lt 3 ]; then # echo "$JOBNAME_SHORT: Cannot remove file(s) modified less than" # echo "$JOBNAME_SHORT: $RTIME days ago. Aborting.." # exit ${ERROR} #fi
echo "$JOBNAME_SHORT: Cannot find $CHECKDIR directory. Aborting.."
exit ${ERROR}
else
# add directory filter=20
ADMIN=3D/ora/admin
TOOLS=3D/ora/admin/maint
MONITOR=3D/ora/admin/monitor
DATA1=3D/ora/data/da001
DATA2=3D/ora/data/da002
#ARCHIVE=3D/ora/archive
if [ "${ORACLE_HOME}" =3D "" ]; then
ORACLE_HOME=3D/ora/product/v7343
fi
if [ `echo $CHECKDIR |grep -c $ORACLE_HOME` -gt 0 -o "${CHECKDIR}" =
=3D "${ADMIN}" -o "${CHECKDIR}" =3D "${TOOLS}" -o "${CHECKDIR}" =3D =
"${MAINT}" -o "${CHECKDIR}" =3D "${MONITOR}" -o "${CHECKDIR}" =3D =
"${DATA1}" -o "${CHECKDIR}" =3D "${DATA2}" ]; then=20
echo "$JOBNAME_SHORT: Cannot delete files from $CHECKDIR = directory. Aborting.."
exit ${ERROR}
fi
# Remove all files that have hnot been accessed or modified=20
# more than RTIME dats
RET=3D${NOTFOUND}
for FILE in `find ${CHECKDIR} ! -type d ! -type l -mtime +${RTIME} =
-user $OWNER 2>/dev/null`; do=20
if [ -s ${FILE} -a ${FILE} -a ${FILE} !=3D "*" -a ${FILE} !=3D "" -a = `echo "${FILE}" | grep -c "*"` -eq 0 ]; then
#echo "${JOBNAME_SHORT}: Moving $FILE file to" #echo "${JOBNAME_SHORT}: $DELETE directory..." #mv $FILE $DELETE=20 echo "${JOBNAME_SHORT}: Removing $FILE ..." rm $FILE=20 if [ $? -ne 0 ]; then echo "${JOBNAME_SHORT}: WARNING: Failed to remove ${FILE}" RET=3D${WARNING} else RET=3D${SUCCESS} fi fi
$SUCCESS)
echo "${JOBNAME_SHORT}: Completed succesfully!" break;; $WARNING) echo "${JOBNAME_SHORT}: Completed with warning!" break;; $NOTFOUND) echo "${JOBNAME_SHORT}: No files last modified more than $RTIME = days" echo "${JOBNAME_SHORT}: found in ${CHECKDIR} directory!" break;;
------_=_NextPart_000_01C0542F.93CA0DA4
Content-Type: application/octet-stream;
name="dbarccln.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="dbarccln.sh"
#! /bin/ksh # name dbarccln.sh =20 # # purpose Check space in /ora/archive direcrory and clean it ( move to=20 # another location and compress ) if it reached the limit = # # usage dbarccln=20 # # parameters none=20 # ..............................................................# booleans
TOOLS=3D/ora/admin/bin =20 BACKUPDIR=3D/orabackup =20 DONEDIR=3D/da001/ontape=20
echo "$JOB: `date '+%H:%M:%S'` ${JOB} is already running. Exiting = ..."
exit $ERROR
fi
# Check if any archive destanation reached the limit
print -n "$JOB: `date '+%H:%M:%S'` Getting used space in $ARC ... "
CAPACITY=3D`df -k $ARC 2>/dev/null | tail -1 | awk '{print $5}'| cut -d =
"%" -f1`
print ${CAPACITY}%
if [ ${CAPACITY} -lt ${ULIMIT} ]; then
echo "$JOB: `date '+%H:%M:%S'` ${ARC} has not reached the limit =
(${ULIMIT}%)."
echo "$JOB: `date '+%H:%M:%S'` Exiting now ..."
exit $SUCCESS
fi
# check directories
if [ ! -s ${BACKUPDIR} ]; then
echo "$JOB: `date '+%H:%M:%S'` ERROR: Cannot find ${BACKUPDIR} = directory."=20
echo "$JOB: `date '+%H:%M:%S'` ERROR: Aborting.."
exit ${ERROR}
fi
if [ ! -s ${DONEDIR} ]; then
echo "$JOB: `date '+%H:%M:%S'` ERROR: Cannot find ${DONEDIR} = directory."=20
echo "$JOB: `date '+%H:%M:%S'` ERROR: Aborting.."
exit ${ERROR}
fi
# Logs=20
LOGS=3D${TOOLS}/LOGS
if [ ! -s $LOGS ]; then
mkdir $LOGS
if [ $? -ne 0 ]; then
echo "$JOB: `date '+%H:%M:%S'` ERROR: Failed to create ${LOG} = directory."
echo "$JOB: `date '+%H:%M:%S'` ERROR: Aborting..." exit ${ERROR}
UTILSLOG=3D"$LOGS/${JOB}_`date '+%y%m%d'`.log"
fi
echo "$JOB: `date '+%H:%M:%S'` Output is redirected to "
echo "$JOB: `date '+%H:%M:%S'` to ${UTILSLOG}"
#
BACKUP_ARC=3D"$BACKUPDIR/`basename $JOB .sh`_`date '+%y%m%d'`.tar"
PREFIX=3D1
while [ -s ${BACKUP_ARC} -o -s ${BACKUP_ARC}.Z ]
do
PREFIX=3D`expr $PREFIX + 1`
BACKUP_ARC=3D"$BACKUPDIR/${ORACLE_SID}_arc_`date =
'+%y%m%d'_${PREFIX}`.tar"
done
IN=3D$FALSE
echo "$JOB: `date '+%H:%M:%S'` Removing files from $DONEDIR"
echo "$JOB: `date '+%H:%M:%S'` that have not been modified"
print -n "$JOB: `date '+%H:%M:%S'` for the last ${DONE_KEEP} day(s) =
... "
# Cleanup DONE location =20
for FILE in `find ${DONEDIR}/* -mtime +${DONE_KEEP} 2>/dev/null`; do
if [ ${IN} -eq ${FALSE} ]; then
print=20 IN=3D$TRUE
print -n "$JOB: `date '+%H:%M:%S'` $FILE ..." rm ${FILE} if [ $? -ne 0 ]; then print "Failed"=20 else print "OK"=20 fi
print "No fileS found"=20
fi
# Cleanup BACKUP destination=20
IN=3D$FALSE
echo "$JOB: `date '+%H:%M:%S'` Moving files from $BACKUPDIR that have" echo "$JOB: `date '+%H:%M:%S'` not been modified for the last " echo "$JOB: `date '+%H:%M:%S'` for the last ${BACKUP_KEEP} day(s)"print -n "$JOB: `date '+%H:%M:%S'` into ${DONEDIR} ... " for FILE in `find ${BACKUPDIR}/* -mtime +${BACKUP_KEEP} 2>/dev/null`; = do
if [ ${IN} -eq ${FALSE} ]; then
print=20 IN=3D$TRUE
print -n "$JOB: `date '+%H:%M:%S'` ${FILE} ... " mv $FILE ${DONEDIR} if [ $? -ne 0 ]; then print "Failed"=20 else print "OK"=20 fi
print "No files found"=20
fi
IN=3D$FALSE
echo "$JOB: `date '+%H:%M:%S'` Compessing ${ARC} files" echo "$JOB: `date '+%H:%M:%S'` that have not been modified " echo "$JOB: `date '+%H:%M:%S'` for the last ${ARCHIVE_KEEP} day(s)"print -n "$JOB: `date '+%H:%M:%S'` and moving to $BACKUPDIR" for FILE in `find ${ARC}/* -mtime +${ARCHIVE_KEEP} ! -name \*.Z ! -type = d 2>/dev/null`; do
if [ ${IN} -eq ${FALSE} ]; then
print=20 IN=3D$TRUE
print "Failed"
else
print "OK"
fi
b_name=3D`basename ${FILE}.Z`
d_name=3D`dirname ${FILE}.Z`
print -n "$JOB: `date '+%H:%M:%S'` Adding to the tar file ... "
if [ ! -f ${BACKUP_ARC} ]; then
tar cvf ${BACKUP_ARC} -C ${d_name} ./${b_name} >> ${UTILSLOG} else
tar uvf ${BACKUP_ARC} -C ${d_name} ./${b_name} >> ${UTILSLOG}
fi
if [ $? -ne 0 ]; then
print "Failed"
else
print "OK" print -n "$JOB: `date '+%H:%M:%S'` Moving to ${DONEDIR} ... " mv ${FILE}.Z ${DONEDIR} if [ $? -ne 0 ]; then print "Failed" else print "OK" NEWNAME=3D${DONEDIR}/`basename ${FILE}.Z` print -n "$JOB: `date '+%H:%M:%S'` Touching ${NEWNAME} ... " touch ${NEWNAME} if [ $? -ne 0 ]; then print "Failed" else print "OK" fi fiReceived on Tue Nov 21 2000 - 20:54:40 CST