Persisting Logs
By default, CentOS/RHEL 7 stores the system journal in /run/log/journal, which is stored on a tmpfs. This implies that on a reboot all stored information will be lost.
If the directory /var/log/journal is present the journal will be stored there, thus enabling a persistent journal across reboots.
Enabling a persistent journal can be done by using the following steps:
1 Create the directory /var/log/journal.
2 Set the group ownership of the new directory to systemd-journal, and the permissions to 2755.
chown root:systemd-journal /var
/log/journal
chmod 2755 /var/log
/journal
3 Inform systemd-journald that the new location should be used by sending a USR1 signal to it. A reboot will also suffice.
killall -USR1 systemd-journald
3a Alternatively you can edit the journal configuration file:
sudo nano /etc/systemd
/journald.conf
. . .
[Journal]
Storage=persistent
Cleaning Up Logs
Finding Current Disk Usage
Deleting Old Logs
journalctl --vacuum-size=1G #by size
journalctl --vacuum-time=1years #by timespan (deletes older than 1years)
Limiting Journal
You can configure your server to place limits on how much space the journal can take up. This can be done by editing the
/etc/systemd/journald.conf
file.
The following items can be used to limit the journal growth:
•
SystemMaxUse=
: Specifies the maximum disk space that can be used by the journal in persistent storage.
•
SystemKeepFree=
: Specifies the amount of space that the journal should leave free when adding journal entries to persistent storage.
•
SystemMaxFileSize=
: Controls how large individual journal files can grow to in persistent storage before being rotated.
•
RuntimeMaxUse=
: Specifies the maximum disk space that can be used in volatile storage (within the
/run
filesystem).
•
RuntimeKeepFree=
: Specifies the amount of space to be set aside for other uses when writing data to volatile storage (within the
/run
filesystem).
•
RuntimeMaxFileSize=
: Specifies the amount of space that an individual journal file can take up in volatile storage (within the
/run
filesystem) before being rotated.