Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pvillamil/7796f41f7e6cbb79e1b1a7d7afb5355a to your computer and use it in GitHub Desktop.
Save pvillamil/7796f41f7e6cbb79e1b1a7d7afb5355a to your computer and use it in GitHub Desktop.
Clear Systemd Journal Logs in Ubuntu 20.04

Clear Systemd Journal Logs in Ubuntu 20.04

Systemd has its own logging system called the journal, and the log files are stored in /var/log/journal.

Check current disk usage of journal files

sudo journalctl --disk-usage

Rotate journal files

  • Active journal files will be marked as archived, so that they are never written to in future.
sudo journalctl --disk-usage

Delete journal logs older than 5 days:

sudo journalctl --vacuum-time=5days

Delete log files until the disk space taken falls below 200M:

sudo journalctl --vacuum-size=200M

Delete old logs and limit file number to 10:

sudo journalctl --vacuum-files=10

The configuration file is located at /etc/systemd/journald.conf. After editing to your preference, reload systemd daemon using sudo systemctl daemon-reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment