|
|
|
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...What's New:HintsNo new hintsComments last 2 days
Links last 2 weeksNo recent new linksWhat's New in the Forums?
The Editor's Corner...Here are some of my (robg) other projects...
Hints by TopicNews from Macworld
The macosxhints PollWhat version of OS X are you running as your main OS?
Other polls | 11,370 votes | 42 comments
|
|
Copyright © 2009 Mac Publishing LLC (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Powered by Geeklog Created this page in 0.03 seconds |
|