How to cleanup a /var/log/journal in Linux
You may find your /var/log/journal
directory taking up a lot of disk-space.
How do you go about removing, or deleting all these files under var log journal
without the system complaining and falling over?
How to tell how much space is being taken?
You can ask the journalctl
command directly, using the --disk-usage
argument:
|
|
It will report something like this:
Journals take up 3.9G on disk.
Fix: Option 1 (not ideal):
Go and adjust its config under /etc/systemd/journald.conf
, making sure to pay attention to the SystemMaxUse
key; set this to something reasonable, like 50M
perhaps.
At this point you can force a log rotation by issuing this command:
|
|
Remember to restart the systemctl
process, like this:
|
|
Fix: Option 2 (not recommended):
You could always go and delete the offending /var/log/journal/**
directory contents, but this is not the recommended way, as the system journal could be writing here, which will probably cause you bigger problems!
Fix: Option 3 (RECOMMENDED!):
Simply run the following command to cleanup the /var/log/journal
directory:
|
|
This will delete old log files until the directory reaches the threshold size stipulated, in our case, 500M.
It really is that easy to clear or clean up your var log journal!