OS X Server - how to rotate logs

root's picture

You can use the systems newsyslog daemon to periodically zip, rotate, and ultimately trash the logs.

The configuration file is here:

osx:~ root# ls -la /private/etc/newsyslog.conf
-rw-r--r--  1 root  wheel  1590 Nov 14 21:04 /private/etc/newsyslog.conf

As you may see, there are some logs configured but not everything is covered:

osx:~ root# grep -v ^# /private/etc/newsyslog.conf
/var/log/appfirewall.log		640  5     1000	*     J
/var/log/ftp.log			640  5	   1000	*     J
/var/log/hwmond.log			640  5	   1000	*     J
/var/log/install.log			640  5	   1000	*     J
/var/log/ipfw.log			640  5	   1000	*     J
/var/log/lookupd.log			640  5	   1000	*     J
/var/log/lpr.log			640  5	   1000	*     J
/var/log/mail.log			640  5	   1000	*     J
/var/log/ppp.log			640  5	   1000	*     J
/var/log/secure.log			640  5	   1000	*     J
/var/log/system.log			640  7	   *	@T00  J
/var/log/wtmp				644  3	   *	@01T05 B

Now we will try to configure this logrotation for other logs but first we have to look at the manual:

osx:~ root# man 5 newsyslog.conf

Do as you wish, I have configured some of my logs as follows:

/Library/Logs/WebConfig.log		640  30    10240 *    J	
/Library/Logs/WebDAVSharing.log		640  30    10240 *    J
/Library/Logs/WikiConfig.log		640  30    10240 *    J
/Library/Logs/AppleFileService/AppleFileServiceAccess.log 644 30 10240 * J /private/var/run/AppleFileServer.pid
/Library/Logs/AppleFileService/AppleFileServiceError.log 644 30 5120 * J /private/var/run/AppleFileServer.pid

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root