Skip to main content

Aufbewahrungszeit Journal von Systemd konfigurieren

Getestet mit Arch Linux am 25.09.2020

Mit der Zeit wird das Journal (der /var/log/syslog Ersatz von Systemd) immer länger. Es läßt sich aber auch eine Retention konfigurieren, die z.B. die Logs nach einer Woche löscht. Dazu muss die Konfigurationsdatei wie folgt editiert werden:

MaxRetentionSec=1week

Aus der Manpage zu journald.conf:

MaxRetentionSec=
  The maximum time to store journal entries. This controls whether journal files containing entries older than the specified time span are deleted. Normally, time-based deletion of old journal files 
  should not be required as size-based deletion with options such as SystemMaxUse= should be sufficient to ensure that journal files do not grow without bounds. However, to enforce data retention 
  policies, it might make sense to change this value from the default of 0 (which turns off this feature). This setting also takes time values which may be suffixed with the units "year", "month", 
  "week", "day", "h" or " m" to override the default time unit of seconds.

Es gibt noch ein paar andere Möglichkeiten, z.B. nach einer bestimmten Größe zu rotieren. Diese sind in der Manpage dokumentiert: man journald.conf