OSX /var/log/system.log – 我在哪里定义修剪间隔?

我有一个定期检查/var/log/system.log的脚本,我注意到我们的networking中有些机器通过重新启动和其他活动将日志文件保留一个月,而有些机器每晚或每次重启都会清除文件。

有没有人知道这里的确切规则,或者如果我可以指定时间间隔? 提前致谢。

在OS X上,/ newsyslognewsyslog运行一次的newsyslog命令进行轮换(请参阅/System/Library/LaunchDaemons/com.apple.newsyslog.plist)和清醒。 循环规则在/etc/newsyslog.conf中,相关的行是:

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

如果我理解了这个权限(请参阅newsyslog.conf手册页 ),则“when”字段中的“@ T00”表示如果newsyslog在午夜和凌晨1点之间运行 – 即在上午12:30运行,日志将被轮换。 但是,如果Mac在12:30rest或者睡着了,这个运行就不会发生,并且日志不会在当天被轮换,这可能是为什么你看到这样的variables结果。

如果你想改变旋转标准,可以编辑/etc/newsyslog.conf; 大多数其他日志是基于大小旋转,我不知道为什么system.log是不同的。

更新:从10.9开始,system.log的旋转控制从/etc/newsyslog.conf移动到/etc/asl.conf(苹果系统日志工具的configuration,写入system.log)。 它会有一个这样的部分:

 # Rules for /var/log/system.log > system.log mode=0640 format=bsd rotate=seq compress file_max=5M all_max=50M ? [= Sender kernel] file system.log ? [<= Level notice] file system.log ? [= Facility auth] [<= Level info] file system.log ? [= Facility authpriv] [<= Level info] file system.log 

“rotate = seq compress file_max = 5M all_max = 50M”部分控制归档和保留。 请参阅man asl.conf了解更多信息和选项。

日志logging系统在10.12中得到了相当彻底的重写,但是这似乎没有改变。