Information
The journald system includes the capability of compressing overly large files to avoid filling up the system with logs or making the logs unmanageably large.
Uncompressed large files may unexpectedly fill a filesystem leading to resource unavailability. Compressing logs prior to write can prevent sudden, unexpected filesystem impacts.
Solution
Set the following parameter in the [Journal] section in /etc/systemd/journald.conf or a file in /etc/systemd/journald.conf.d/ ending inconf :
Compress=yes
Example:
#!/usr/bin/env bash
{
[ ! -d /etc/systemd/journald.conf.d/ ] && mkdir /etc/systemd/journald.conf.d/
if grep -Psq -- '^h*[Journal]' /etc/systemd/journald.conf.d/60-journald.conf; then
printf '%s
' "Compress=yes" >> /etc/systemd/journald.conf.d/60-journald.conf
else
printf '%s
' "[Journal]" "Compress=yes" >> /etc/systemd/journald.conf.d/60-journald.conf
fi
}
Note: If this setting appears in a canonically later file, or later in the same file, the setting will be overwritten
Run to following command to update the parameters in the service:
# systemctl reload-or-restart systemd-journald