Is logrotate hiding somewhere on OSX, or is there an equivalent? It's not in /usr/sbin.

link|improve this question

44% accept rate
Why the downvote? – Steve Bennett Jan 24 at 0:40
I dunno why you got a downvote, so I upvoted it. I think it's a good question. – Tom O'Connor Jan 24 at 0:45
I notice there is newsyslog, but that's not quite the same and requires root. – Steve Bennett Jan 24 at 1:05
Can logrotate be ported, i wonder. – Tom O'Connor Jan 24 at 1:28
check /etc/periodic, I believe that log rotation is by default implemented as a set of shell scripts in there. Also look at newsyslog (/etc/newsyslog.d and man page) for a way to do it based on file size. – malcolmpdx Jan 24 at 4:56
show 1 more comment
feedback

3 Answers

up vote 3 down vote accepted

OS X has several ways to rotate/expire/etc its logs, depending on the type of log in question:

  1. For regular log files (i.e. text files that are continuously appended to), newsyslog can rotate them based on size or time, although it doesn't seem to have as many options as logrotate. It's configured by /etc/newsyslog.conf and /etc/newsyslog.d/* (generally, you should add files to /etc/newsyslog.d/ to add logs to its management list).
  2. OS X's syslog system is migrating from this plain-text format to database format, mainly in /var/log/asl/. I don't entirely understand this system yet, but this database seems to be purged by aslmanager, which is configured by /etc/asl.conf.
  3. For directories that have individual log "entries" added as separate files (mainly /Library/Logs/CrashReporter/), the files get purged by /etc/periodic/daily/100.clean-logs. Its policies (which directories to scan & how long to leave files) are configured in /etc/defaults/periodic.conf, but if you want to override/change them you should create /etc/periodic.conf.local and put your customizations there.

If what you want to rotate doesn't fit any of these models, you can add your own scripts to /etc/periodic/daily/ (which'll be run every morning at 3:15am), /etc/periodic/weekly/ (every saturday morning at 3:15am), or /etc/periodic/monthly/ (first of every month at 5:30am).

link|improve this answer
feedback

newsyslog runs automatically on OSX, I use a config file like this in /etc/newsyslog.d/rails_apps.conf to keep my dev log files trimmed to 5MB

# logfilename                           [owner:group]   mode count size     when  flags [/pid_file] [sig_num]
/Users/barmstrong/code/**/log/*.log                     666  0     5242880  *     G
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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