syslog:在 ubuntu 上,如何配置 syslog 文件的轮换和 gzip 压缩?

发布于 2024-08-30 19:20:48 字数 221 浏览 12 评论 0原文

如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

比忠 2024-09-06 19:20:48

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文