Systemd Journal Logrotate 实现

Systemd Journal Logrotate 实现


1. 利用 systemd-journald 提供的客户端 journal 实现;

1
2
journalctl --vacuum-size=10M
journalctl --vacuum-time=1days


man journal

1
2
3
4
5
6
--vacuum-size=, --vacuum-time=
Removes archived journal files until the disk space they use falls below the specified size (specified with the usual "K", "M", "G", "T" suffixes), or
all journal files contain no data older than the specified timespan (specified with the usual "s", "min", "h", "days", "months", "weeks", "years"
suffixes). Note that running --vacuum-size= has only indirect effect on the output shown by --disk-usage as the latter includes active journal files,
while the former only operates on archived journal files. --vacuum-size= and --vacuum-time= may be combined in a single invocation to enforce both a
size and time limit on the archived journal files.


参考资料:


http://blog.51cto.com/molewan/2043336


https://www.lulinux.com/archives/3135


https://blog.csdn.net/zstack_org/article/details/56274966


https://hk.saowen.com/a/e87c9aea9fda48e01d04a56a0bf87b31917eaa1be7ed8ef14df8c805d2fc54b1


https://blog.selectel.com/managing-logging-systemd/


https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs


https://huataihuang.gitbooks.io/cloud-atlas/os/linux/redhat/system_administration/systemd/systemd_clear_journalctl.html


http://www.jinbuguo.com/systemd/journalctl.html


https://www.kancloud.cn/wizardforcel/vbird-linux-basic-4e/152347





2. 利用配置 systemd-journald 保存的最大日志容量实现, 配置文件为 /etc/systemd/journald.conf 。

1
2
3
...
SystemMaxUse=50M
...


参考资料:


https://huataihuang.gitbooks.io/cloud-atlas/os/linux/redhat/system_administration/systemd/systemd_clear_journalctl.html


https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs


http://os.51cto.com/art/201405/440886.htm