Persistent journald log

I’m trying to implement a script as a service to run at shutdown, but before network gets down. Since I cannot get it to work (which is not the question here), I want to check the shutdown logs.
But I cannot get them to stay persistent.
I tried leaving the settings in /etc/systemd/journald.conf alone and just doing
mkdir /var/log/journal. This leaves /var/log/journal empty.
And I tried setting

[Journal]
Storage=persistent

inside /etc/systemd/journald.conf, which at least produces files inside /var/log/journal, but still they don’t survive a reboot.
How do I know?
journalctl only shows -- Journal begins at and then the time of the current boot. As well as journalctl --list-boots lists only one boot, the current one, line starting with 0.

So, what am I doing wrong, how can I get the systemd journal to stay persistent?

Welcome to our

You could try following to get persistent system logs:

dietpi-software uninstall 103 # uninstalls DIetPi-RAMlog
mkdir /var/log/journal # triggers systemd-journald logs to disk
reboot # required to finalise the RAMlog uninstall

Then you can check system logs via:

journalctl

which will then show as well logs from previous boot sessions. To limit the size, you can additionally e.g. apply the following:

mkdir -p /etc/systemd/journald.conf.d
cat << '_EOF_' > /etc/systemd/journald.conf.d/99-custom.conf
[Journal]
SystemMaxFiles=2
MaxFileSec=7day
_EOF_

This will limit logs to 14 days split across two journal files, so that with rotation you will always have between 7 and 14 days of logs available.

1 Like

Ah, great, that’s what I was missing, thank You very much, now it works.
Hopefully now I can find a solution for the initial problem.