Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a script that periodically checks /var/log/system.log and I've noticed across our network that some machines keep logfiles for a month through reboots and other activities, while some purge the file each night or each reboot.

Does anyone know the exact rules here, or if I can specify intervals? Thanks in advance.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

On OS X, /var/log/system.log is rotated by the newsyslog command, which is run at half-past each hour (see /System/Library/LaunchDaemons/com.apple.newsyslog.plist) whenever the Mac is running and awake. The rotation rules are in /etc/newsyslog.conf, from which the relevant lines are:

# logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
/var/log/system.log                     640  7     *    @T00  J

If I understand this right (see the newsyslog.conf man page), the "@T00" in the "when" field means that the log will be rotated if newsyslog runs between midnight and 1am -- i.e. at the 12:30am run. But if the Mac is off or asleep at 12:30, this run won't happen and the log won't get rotated that day, which is probably why you see such variable results.

If you want to change the rotation criteria, feel free to edit /etc/newsyslog.conf; most of the other logs get rotated based on size, and I'm not sure why system.log is different.

share|improve this answer
    
Great answer, wish I could upvote twice. Thanks a ton! –  David Houde Apr 29 '11 at 12:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.