write a basic shell script and pop it on the cron eg, the one we use to roll the logs and delete old ones is (it leaves 3days of logs for you - still i test, but it looks to work):
1) copy catalina.out to one site and rename it(this will become the archive)
2) clear out catalina.out
3) delete all files over a set age
This script was designed for itterating through a log dir and its sub dirs (hence the use of find) deleting all files over a set age and rolling those that didnt roll themselves.
view plaincopy to clipboardprint?
#!/bin/ksh
export DAYS=$1
export LOG_DATE=`date '+%G%m%d'`
if [ -z "$DAYS" ]
then
echo "Missing argument : You must define how many days (from the beginning" 1>&2
echo " of today) logs you wish to keep" 1>&2
exit 1
fi
find ${LOGAREA} -type f -name 'catalina.out' -exec /bin/cp {} {}.log.$LOG_DATE \;
find ${LOGAREA} -type f -name 'catalina.out' -exec /bin/cp /dev/null {} \;
find ${LOGAREA} -type f -name 'catalina.out.*' -mtime +${DAYS} -exec /bin/rm -f {} \;
exit 0
1) copy catalina.out to one site and rename it(this will become the archive)
2) clear out catalina.out
3) delete all files over a set age
This script was designed for itterating through a log dir and its sub dirs (hence the use of find) deleting all files over a set age and rolling those that didnt roll themselves.
view plaincopy to clipboardprint?
#!/bin/ksh
export DAYS=$1
export LOG_DATE=`date '+%G%m%d'`
if [ -z "$DAYS" ]
then
echo "Missing argument : You must define how many days (from the beginning" 1>&2
echo " of today) logs you wish to keep" 1>&2
exit 1
fi
find ${LOGAREA} -type f -name 'catalina.out' -exec /bin/cp {} {}.log.$LOG_DATE \;
find ${LOGAREA} -type f -name 'catalina.out' -exec /bin/cp /dev/null {} \;
find ${LOGAREA} -type f -name 'catalina.out.*' -mtime +${DAYS} -exec /bin/rm -f {} \;
exit 0
No comments:
Post a Comment
Thank You for your Comments, We will read and response you soon...