Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 103System · Logs

How to keep the journal after reboot and limit its size

The server crashed and rebooted — and journalctl shows nothing from before the reboot, because the journal was only in memory. Or the opposite: /var/log/journal has grown to 8 GB. This how-to makes the systemd journal persistent, sets size and age limits, reads logs of the previous boot, and cleans up space now.

  • 5 Lessen
  • 7 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

103.1

The quick answer

/etc/systemd/journald.conf.d/10-persistent.conf
[Journal]
Storage=persistent
SystemMaxUse=1G
MaxRetentionSec=1month
systemctl restart systemd-journald
journalctl --list-boots | tail -3
journalctl --disk-usage

103.2

Step by step

  1. Is it persistent now? If --list-boots shows only the current boot (0), older boots are lost:
journalctl --list-boots | tail -3
 -2 3a1f… Mon 2026-11-17 02:10:01 +03—Tue 2026-11-18 03:12:44 +03
 -1 8c2e… Tue 2026-11-18 03:13:20 +03—Thu 2026-11-19 10:01:02 +03
  0 f4d9… Thu 2026-11-19 10:01:40 +03—Thu 2026-11-19 10:42:07 +03
ls -d /var/log/journal 2>/dev/null || echo "volatile only"
  1. Make it persistent — the drop-in file (quick answer). Storage=persistent creates /var/log/journal and keeps logs there.
  2. Set limits so it never fills the disk:
SettingMeans
SystemMaxUse=1GTotal size on disk.
SystemKeepFree=2GAlways leave this much free on the file system.
MaxRetentionSec=1monthDelete entries older than a month.
MaxFileSec=1weekStart a new file each week (faster cleanup).
  1. Restart journald (quick answer) — no reboot needed.
  2. Read the previous boot — the key use after a crash:
journalctl -b -1 -p warning --no-pager | tail -40
journalctl -b -1 -e

-b -1 = the boot before this one, -p warning = warnings and worse, -e = jump to the end (the last lines before the crash).

  1. Free space now (keeps the newest entries):
journalctl --vacuum-size=500M
journalctl --vacuum-time=2weeks
  1. Still need text files or central logs? rsyslog can write classic files from the journal, and Fluent Bit / Promtail can ship the journal to Loki or Elasticsearch.

103.3

Check that it worked

After the next reboot, journalctl --list-boots shows more than one boot, journalctl -b -1 shows the old boot, and journalctl --disk-usage stays under your limit.

103.4

Common problems

ProblemCauseFix
Only boot 0 is listedStorage is volatile (/run/log/journal).Storage=persistent and restart journald.
/var/log/journal exists, still not keptWrong owner/ACLs after a manual mkdir.systemd-tmpfiles --create --prefix /var/log/journal, restart journald.
The journal uses many GBNo SystemMaxUse (default up to 10 % of the FS, max 4 GB).Set limits; --vacuum-size.
Journal file … is truncated, ignoring fileCrash during a write.Normal after a crash; old entries in other files stay.
Normal users see few logsOnly own logs without the right group.Add admins to systemd-journal or wheel/adm.
The time in old boots looks wrongClock was not synced at that boot.Fix NTP; logs keep the time the system had.

103.5

Go further

1How do you read the logs from before the last reboot?

journalctl -b -1 — this needs a persistent journal.

2Which setting limits the journal's size on disk?

SystemMaxUse= in journald.conf (or a drop-in file).

Alle commando's in dit hoofdstuk