Hi,
I want to trim the listner.log periodically by a cron job keeping copy of the original alert.log.
Any one has any shell script for this.
Please help.
Printable View
Hi,
I want to trim the listner.log periodically by a cron job keeping copy of the original alert.log.
Any one has any shell script for this.
Please help.
You can Google oracle rotate listener log and try one of the 100,000 plus hits on this topic.
Do you mean listener log or the alert log, since you mention both in your question? What do you mean by trim? Keep part of the original in the new version of the file? Or do you mean rotate?
I want to copy the listener.log file to other file with todays date. Then make the original file with 0 bytes.
You can add this code snippet to your script:
:pCode:####### Cleanup Network Logs ######
########### Start #############
for file in `ls $NET_DIR/*.log`
do
if [ `ls -ltr $file|awk '{print $5}'` -gt 10485760 ] # 10MB
then
NEWFILE=$file.`date +%m%d%y`
cp -p $file $NEWFILE
cp /dev/null $file
echo "Log File Moved: $file"
gzip $NEWFILE
find $NET_DIR -name "*.gz" -mtime +60 -exec rm {} \; 2>/dev/null
fi
done