journalctl 用来查询 systemd-journald 服务收集到的日志systemd-journald 服务是 systemd init 系统提供的收集系统日志的服务。

 

Ubuntu journalctl默认日志不保存在硬盘,需要设置保存在硬盘以便查看

 

systemd-journald 服务收集到的日志默认保存在 /run/log 目录中,重启系统会丢掉以前的日志信息。 我们可以通过两种方式让 systemd-journald 服务把所有的日志都保存到文件中,这样重新启动后就不会丢掉以前的日志。

方法一:创建目录 /var/log/journal,然后重启日志服务 systemd-journald.service。

方法一的详细操作

在 /var/log/ 下面创建名为 journal 的目录,并设置权限即可:

$ sudo mkdir /var/log/journal

$ sudo chown root:systemd-journal /var/log/journal

$ sudo chmod 2775 /var/log/journal

$ sudo systemctl restart systemd-journald.service

 

之后 /run/log 下面就没有 journal 的日志了,日志文件被保存在 /var/log/journal 目录下:

 ubuntu 16.04配置journalctl

 

 

方法二:修改配置文件

 /etc/systemd/journald.conf,把 Storage=auto 改为 Storage=persistent,并取消注释,然后重启日志服务。

重启服务:

sudo systemctl restart systemd-journald.service

 

检查:

ubuntu 16.04配置journalctl

 

 

 

 

 

 

相关文章:

  • 2022-01-29
  • 2021-11-13
  • 2021-11-20
  • 2021-10-24
  • 2021-05-07
  • 2021-10-14
  • 2021-07-12
猜你喜欢
  • 2022-01-19
  • 2021-05-30
  • 2022-03-04
  • 2022-12-23
  • 2021-06-06
  • 2021-10-31
相关资源
相似解决方案