Why journalctl logs disappear after reboot and how to make it permanent ?
By default, Journald logs gets stored in /run/log/journal directory and disappear once the system gets rebooted.
I. Default Journald configuration
[root@localhost ~]# date Wed Mar 13 10:50:29 PDT 2019 [root@localhost ~]# uptime 10:51:17 up 1:23, 1 user, load average: 0.00, 0.01, 0.05 ### We can see the logs were started at ### 09:27 PDT i.e. just after system boot ### All old logs are removed. [root@localhost ~]# journalctl | more -- Logs begin at Wed 2019-03-13 09:27:20 PDT, end at Wed 2019-03-13 10:50:01 PDT . -- Mar 13 09:27:20 localhost.localdomain systemd-journal[86]: Runtime journal is us ing 8.0M (max allowed 89.5M, trying to leave 134.2M free of 887.0M available → cu rrent limit 89.5M). Mar 13 09:27:20 localhost.localdomain kernel: Initializing cgroup subsys cpuset Mar 13 09:27:20 localhost.localdomain kernel: Initializing cgroup subsys cpu Mar 13 09:27:20 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Mar 13 09:27:20 localhost.localdomain kernel: Linux version 3.10.0-957.el7.x86_6 4 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8. 5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018
II. Making Journald configuration to store logs permanently
To store Journald logs permanently, we need to change its configuration.
Here are the steps.
# PRE-CHECKS
### Get before activity logs. [root@localhost ~]# uptime 10:51:17 up 1:23, 1 user, load average: 0.00, 0.01, 0.05 [root@localhost ~]# date Wed Mar 13 10:53:05 PDT 2019
# CONFIGURATION
# POST-CHECKS
### Checkout the newly created data file. [root@localhost ~]# file /var/log/journal/974de63103a847d3a6879c9a69b0c1b8/system.journal /var/log/journal/974de63103a847d3a6879c9a69b0c1b8/system.journal: data [root@localhost ~]# ### Restart the system and verify if old logs are there. ### After modifying file /etc/systemd/journald.conf file, it is advisable to reboot [root@localhost ~]# init 6 ### Now check logs again after system boot ### The logs still exists from the same old date till it reaches 100M size. [root@localhost ~]# uptime 11:10:26 up 11 min, 4 users, load average: 0.04, 0.26, 0.29 [root@localhost ~]# date Wed Mar 13 11:10:28 PDT 2019 [root@localhost ~]# journalctl | more -- Logs begin at Wed 2019-03-13 09:27:20 PDT, end at Wed 2019-03-13 11:10:18 PDT . -- Mar 13 09:27:20 localhost.localdomain systemd-journal[86]: Runtime journal is us ing 8.0M (max allowed 89.5M, trying to leave 134.2M free of 887.0M available → cu rrent limit 89.5M). Mar 13 09:27:20 localhost.localdomain kernel: Initializing cgroup subsys cpuset