Skip to content

Instantly share code, notes, and snippets.

@bearlike
Created March 8, 2022 07:59
Show Gist options
  • Save bearlike/5d9fa646d1171fa996f09e82ccfc6eb0 to your computer and use it in GitHub Desktop.
Save bearlike/5d9fa646d1171fa996f09e82ccfc6eb0 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

@maartenderie
Copy link

under 'Rotate journal files' I think it should be

sudo journalctl --rotate

Per --help;

--rotate                Request immediate rotation of the journal files

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