|
|
10.5: Allow the system.log file to be rotated daily
Launchd actually runs newsyslog every hour, on the hour. It is because of the default configuration in /etc/newsyslog.conf and a quirk in newsyslog (it will not run a skipped event more than one hour after it was originally scheduled) that the default setup only rotates system.log within an hour of midnight.
It will work to rotate system.log by size, but Unix systems traditionally rotate system.log daily to make the search for error messages simpler. Finally, newsyslog.conf cannot be used to rotate the other files that eventually grow unwieldy, like daily.out, weekly.out, the apache2 logs, and even fsck_hfs.log. Instead, try a script like
#!/bin/sh
# script to rotate logs
rotatelog ()
{
log=$1
size=`ls -l $log | awk '{print $5}'`
if [ $size -gt 50000 ]
then
bzip2 < $log > $log.0.bz2
chmod 0644 $log.0.bz2
> $log
fi
}
newlog ()
{
log=$1
[ -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 > $log.0.bz2
chmod 0644 $log.0.bz2
> $log
}
cd /var/log
rotatelog daily.out
rotatelog weekly.out
cd /var/log/apache2
newlog access_log
newlog error_log
as /etc/weekly.local or /etc/monthly.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.08 seconds |
|