Linux journal log size is too large

Submitted by sysop on Sun, 08/20/2023 - 16:01

Linux journal log size is too large


If the size of your Linux journal log has become too large and is causing issues, you can take the following steps to manage and reduce its size:

  1. Check Log Size: Use the journalctl command to check the size of the journal log:
    journalctl --disk-usage
  2. Limit Log Retention: You can limit the amount of disk space the journal uses by adjusting the retention settings. Edit the journal configuration file:
    sudo vim /etc/systemd/journald.conf

    Find and modify the following lines to set the maximum disk usage and retention time:

    SystemMaxUse=200M    # Set the maximum disk space you want to allocate
    SystemKeepFree=100M  # Set the minimum free space
    SystemMaxFileSize=50M  # Limit the size of individual log files
    MaxRetentionSec=1month # Set the maximum retention time

    Save the file and restart the systemd-journald service:

    sudo systemctl restart systemd-journald
  3. Clear Old Logs: You can clear old logs to free up space using the journalctl command with the --vacuum-size option:
    sudo journalctl --vacuum-size=100M
  4. Archiving Logs: If you need to keep logs for historical purposes, consider archiving older logs to another location. You can use tools like tar or rsync for this purpose.

  5. Monitoring and Rotation: Regularly monitor the log size and implement log rotation mechanisms using tools like logrotate. This ensures that logs are managed efficiently over time.

  6. Investigate High Logging: If your logs are growing rapidly, investigate the cause of excessive logging. It could be due to misconfigured applications or services.

    Remember that managing log files is crucial for maintaining system performance and disk space. Make sure to have backups of important log data before making any major changes to log settings.