当我执行
journalctl
命令时,会得到一个包含所有系统服务的大量日志,但是这些信息都存储在哪里呢?journalctl
命令时,会得到一个包含所有系统服务的大量日志,但是这些信息都存储在哪里呢?man systemd-journald
中得知:FILES
/etc/systemd/journald.conf
Configure systemd-journald behavior. See journald.conf(5).
/run/log/journal/machine-id/*.journal,
/run/log/journal/machine-id/*.journal~,
/var/log/journal/machine-id/*.journal,
/var/log/journal/machine-id/*.journal~
systemd-journald writes entries to files in
/run/log/journal/machine-id/ or /var/log/journal/machine-id/ with
the ".journal" suffix. If the daemon is stopped uncleanly, or if
the files are found to be corrupted, they are renamed using the
".journal~" suffix, and systemd-journald starts writing to a new
file. /run is used when /var/log/journal is not available, or when
Storage=volatile is set in the journald.conf(5) configuration file.
man journalctl
所说:journalctl may be used to query the contents of the systemd(1) journal
as written by systemd-journald.service(8).
这些日志由 systemd-journald
服务管理,因此更适当的术语应该是 "journald
日志"。
/run/log
目录下,在重启后将无法保存... - Alexis Wilke/run/log/journal/<machine-id>/*.journal[~]
会被保留直到下一次启动。每次重启都会丢失所有内容。journalctl --list-boot
/var/log
下,除非您通过创建/var/log/journal
目录来激活持久的journald日志使用。通常存储目录是/var/log/journal
或/run/log/journal
,但它不一定存在于您的系统中。
如果您只想检查日志在磁盘上占用的空间量,只需输入:
$ journalctl --disk-usage
存储目录取决于journald的配置。
配置文件为:
/etc/systemd/journald.conf
/etc/systemd/journald.conf.d/*.conf
/run/systemd/journald.conf.d/*.conf
/usr/lib/systemd/journald.conf.d/*.conf
Storage=
"选项控制是否存储日志数据以及存储位置。可能的取值有"volatile
"、"persistent
"、"auto
"和"none
"。默认为"auto
"。volatile
",日志数据将仅存储在内存中,即在/run/log/journal层次结构下(如果需要会创建该目录)。persistent
",数据将优先存储在磁盘上,即在/var/log/journal层次结构下(如果需要会创建该目录),在早期引导和磁盘不可写入时,会回退到/run/log/journal层次结构下(如果需要会创建该目录)。auto
"与"persistent
"类似,但如果需要,不会创建目录/var/log/journal,因此其存在性决定了日志数据的存储位置。none
"关闭所有存储,所有接收到的日志数据都将被丢弃。journalctl
以查找先前的引导日志$ sudo mkdir -p /var/log/journal
$ sudo systemd-tmpfiles --create --prefix /var/log/journal
journalctl
文件大小不变$ sudo journalctl --vacuum-size=200M
Deleted archived journal /var/log/journal/d7b25a27fe064cadb75a2f2f6ca7764e/system@00056515dbdd9a4e-a6fe2ec77e516045.journal~ (56.0M).
Deleted archived journal /var/log/journal/d7b25a27fe064cadb75a2f2f6ca7764e/user-65534@00056515dbfe731d-b7bab56cb4efcbf6.journal~ (8.0M).
Deleted archived journal /var/log/journal/d7b25a27fe064cadb75a2f2f6ca7764e/user-1000@1bbb77599cf14c65a18af51646751696-000000000000064f-00056444d58433e1.journal (112.0M).
Vacuuming done, freed 176.0M of archived journals on disk.
sudo
来执行 --vacuum-size=
。但还是谢谢。 - Doug Smythiescron
的机器人,每个月都会帮我做吸尘的工作 :). 所以我从来不需要在终端中输入命令。我已经更新了答案。 - WinEunuuchs2Unix
journalctl
是你唯一的选择。 - user2284570