Tuesday, December 10, 2019

Preserving the systemd journal


By default systemd journal are stored in /run/log/journal, which means it is cleared when the system reboots.

If the directory /var/log/journal exists, the journal will log to that directory instead.

Steps for preserving journal
[root@serverX ~]# mkdir /var/log/journal
[root@serverX ~]# chown root:systemd-journal /var/log/journal
[root@serverX ~]# chmod 2755 /var/log/journal
[root@serverX ~]# killall -USR1 systemd-journald
[root@serverX ~]# ls /var/log/journal/72e8116c885b46de947ad2ca3d0eba76
system.journal  user-1000.journal

journalctl -b  - shows the log of current boot.
journalctl -b -1 - show th log of previous boot

No comments: