|
|
Manage the periodic logs
It is not a good idea to redirect the output of the periodic commands to /dev/null; valuable debugging and system information is lost forever. It is also not a good idea to turn an orderly Unix filesystem into spaghetti with symbolic links from system files to user directories. If the size of the periodic files is bothersome, they can be automatically rotated with a simple script installed as /etc/daily.local:
#!/bin/sh
# script to rotate logs
# to maintain historical logs, uncomment the three lines
rotatelog ()
{
log=$1
size=`ls -l $log | awk '{print $5}'`
if [ $size -gt 50000 ]
then
# [ -f $log.2.bz2 ] && mv $log.2.bz2 $log.3.bz2
# [ -f $log.1.bz2 ] && mv $log.1.bz2 $log.2.bz2
# [ -f $log.0.bz2 ] && mv $log.0.bz2 $log.1.bz2
bzip2 $log.0.bz2
chmod 0644 $log.0.bz2
> $log
fi
}
cd /var/log
rotatelog daily.out
rotatelog weekly.out
rotatelog monthly.out
The script rotates the logs when they are >50K. If you uncomment the commented lines in the code, the script will save the four most recent versions of each log; otherwise it will save only the most recent log.
The script is run automatically by the periodic daily command; probably best to install it with execution permission (chmod +x /etc/daily.local).
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.12 seconds |
|