Hexa's Blog

How to delete journalctl log safely?

29/04/2023 @ Saigon Linux

First of all, it’s important to know how much space has been used for journalctl log. There are many method to get this information, in this post, I would like to introduce two method.

  • Disk Usage (du command), given that logs stored in /var/log/journal. You can use this following command.
$ du --human-readable --summarize /var/log/journal
3.0G	/var/log/journal

$ du -sh /var/log/journal
3.0G	/var/log/journal
  • Using journalctl --disk-usage
$ journalctl --disk-usage
Archived and active journals take up 2.8G in the file system.

Now, come back to our main topic - deleting journalctl log safely.

  • Delete log data by time, in this example, it only keeo 7-day old data.
$ journalctl --vacuum-time=7d
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/f5393db751dc400898dc12ef55768680.
Vacuuming done, freed 0B of archived journals from /var/log/journal.
  • Delete log data by disk usage, in the following example, it only keeps data up 1GB. This command uses G for Gigabyte, M for Megabyte, K for Kilobyte.
$ journalctl --vacuum-size=1G
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/f5393db751dc400898dc12ef55768680.