syslog:在 ubuntu 上,如何配置 syslog 文件的轮换和 gzip 压缩?
如何在 ubuntu 上配置 syslog 日志文件的轮换?
在我的 /etc/syslog.conf 中,我有这一行:
local1.* /var/log/log.txt
随着时间的推移,出现了以下备份文件:
/var/log/log.txt.0.gz /var/log/log.txt.1.gz
如何配置这些文件的生成频率以及如何清除它们?
how do you configure rotation of syslog log files on ubuntu?
in my /etc/syslog.conf, i have this line:
local1.* /var/log/log.txt
over time, the following backup files have appeared:
/var/log/log.txt.0.gz
/var/log/log.txt.1.gz
how do i configure how often these files get generated, and how to clean them out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ubuntu 使用两种日志轮换机制。
通过 /etc/syslog.conf 配置的系统日志文件通过 /etc/cron.*/sysklogd 轮换,而 /etc/cron.*/sysklogd 又使用 /usr/sbin/ syslogd-listfiles 获取需要轮换的文件列表。
另一个工具是logrotate,它是通过/etc/logrotate.conf和/etc/logrotate.d中的脚本进行配置的。
sysklogd的优点机制是添加到 syslog.conf 的新 syslog 文件会自动轮换,而无需编写额外的 logrotate 脚本。
syslogd-listfiles 有点复杂,它每天轮换一些日志文件,这在不活动的系统上并不总是有用。
因此,我设置
$everything=0 ;
来禁用 . 系统日志条目的每日轮换,从而使默认情况下完全根据日志文件大小进行轮换。Ubuntu uses two log rotation mechanisms.
System log files which are configured via /etc/syslog.conf are rotated through /etc/cron.*/sysklogd which in turn uses /usr/sbin/syslogd-listfiles to get the list of files which need to be rotated.
The other tool is logrotate which is configured through /etc/logrotate.conf and scripts in /etc/logrotate.d
The advantage of the sysklogd mechanism is that new syslog files added to syslog.conf are automatically rotated without writing an extra logrotate script.
syslogd-listfiles is a bit complex and it rotates some logfiles on a daily bases which is not always useful on an inactive system.
So I set
$everything=0 ;
to disable the daily rotation of . syslog entries thus making the default to rotate purely based on log file size.