cd /u01/app/oracle/diag/tnslsnr/sldbodmo0002/listener/trace
zip listener05022014.log.zip listener.log
cat /dev/null > listener.log
In script vorm:
#!/bin/bash logfile=$1 if [ ! -f $logfile ]; then echo "log file not found $logfile" exit 1 fi timestamp=`date +%Y%m%d` newlogfile=$logfile.$timestamp cp $logfile $newlogfile cat /dev/null > $logfile gzip -f -9 $newlogfile
methode LOGROTATE
Use logrotate command in cron to rotate listener logs in some time intervals. Logrotate is designed to help administrators with managing large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files.
Simple configuration:
Add file:
/etc/logrotate.d/oracle
- write this lines into that file:
/oracle/product/10.2.0/network/log/listener.log {
missingok
weekly
rotate 4
compress
create 644 oracle dba
}
Logs will rotate every weak and old ones will be compressed. We will have 4 latest backups.
Geen opmerkingen:
Een reactie posten