Help cleaning up logs in /var/log/journal, can I just delete them?

Hi everyone!
I’ve been noticing that my HA is taking more space than I expected. I had it running in a VirtualBox until a month ago when I received my Home Assistant Yellow and I migrated to it nicely.
Due to supply problems I was able to get a CM4 module with only 16GB of storage, anyway I thought it should be enough since I don’t have too many devices and my setup is simple.

I investigated on how to set the Recorder and how to make my database smaller, and I could shrink it from ~200mb to 65mb. But there was something else taking space.

I struggled to find th right command to put in the SSH command line to find the biggest folders, but I finally got it:
230406 Folder Sizes

So I started finding ways to reduce this folder size and I found two options, one is journalctl rotate or vacuum, but my SSH command line says “command not found” for journalctl. The other was to call the service System Log: Clear All, but this didn’t reduce this folder size.

I’m stuck here, I don’t know if I can just try to delete this folder, or if there is another “correct” way to make it go away. I’m open to suggestions!

Thanks!
Rodrigo

1 Like

You remember your yellow has a M2 slot to add more capacity, right? :wink:

Tip: “du -shc” gives a much friendlier output, and if you want to find the biggest user of space, then combining it with sort makes that easy. “du -shc |sort -hr”

That dir is systemd’s binary journal - and it’s extremely configurable. Here’s a good guide on reducing it, and automatically setting it to only retain a few days: Clear systemd journal

1 Like

Hi @digdilem thanks for your reply.

I just tried the du -shc without any success:
image
It doesn’t seem to offer any details.
The command I used in the first post shows all the folders and subfolders, shows the size in MB for each folder alongside with the path.
And the second command you gave with the “sort” option gives me an error:
image

I’m using the 'SSH & Web Terminal" add-on to access the terminal, is that OK?
Thanks for the guide, I’ll check that out and try to set a limit to the log and see if it helps.

@koying Yes I know! But I already spent too much in the transition to HA (the Yellow took months to ship, it was delayed a couple of times, my SmartThings hub was getting older and I had to buy some hubs to start using HA in an old PC). Plus, I don’t think it makes any sense to run out of space if 10% of the usage is being wasted in logs. I have 30% of free disk space and want to reach 35-40%, but mostly I don’t want it to get filed with useless files.
If you think there is any good reason to keep these logs taking so much space, please let me know! :wink:

R.

Apologies Rodrigo, I use this so often it’s on autopilot and I missed the filespec. Try " du -shc * " - that lists the files.

Looks like that version of linux or that console doesn’t support the -h (which is “Sort the output that was given in human-readable form”. (From debian and rocky, “sort -h” would give " -h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)" as an option). So sorting probably isn’t going to work for you with the -h switch, but you can still find the biggest user with " du -sc * |sort " which will just show numbers of bytes, instead of the G/K/M markers that -h gives you for gigabyte, kilobyte, etc.

1 Like

Ok! Yes, I was noticing there were some unconsistencies with these filters from the posts I read before also. “du -shc *” seems to show the size of the folders but without counting the subfolders. Anyway, that part is solved with the command I posted first, this is not the issue.

I read the guide, and its solution is based on the journalctl command, which as I mentioned before, when I try to use it, it shows “command not found” error. When I try to access from PuTTY it says “-bash: journalctl: command not found”. I read somewhere that I would need root access to use this command. I tried accessing the terminal from “SSH & Web Terminal” and “Terminal & SSH” add-ons, and with PuTTY with the latest add-on. Maybe the command is not even installed? Do you know what else can I try?

Thanks for your help!
Rodrigo

EDIT: SOLVED!!
It seems that as I’m running HAOS, some commands are limited from the web SSH, so I had to connect to SSH as root. To do that, I had to create an auth key from PuTTY, put it in a USB drive and load it into HA. Then connecting from PuTTY with this key, I was finally able to use the journalctl vacuum to remove old logs.
Now the biggest folder in the system is the backups folder, which is already under control :slight_smile:
I’ll keep an eye on this and see if I have to set a limit to the log size.

1 Like

Hi.
I am having a similar problem but it’s located in another folder
/var/log.hdd/journal/4d4f6d7f9df948e6afd380c743b4ba53


that seems to be an armbian (Linux) issue.
This folder contains more 70000 files…
Can anyone, please, help me?
Thaks.
Miguel