FlightAware Discussions

How to Clean the System Logs

To move current logs to archive:
sudo journalctl --rotate

To delete the archived logs:
sudo journalctl --vacuum-time=1sec

 

pi@piaware:~ $ sudo journalctl --rotate
pi@piaware:~ $ sudo journalctl --vacuum-time=1sec

Deleted archived journal /run/log/journal/6bad2a7eb9f345f09607d96d90952214/system@27769cc7efce4c749e779b9d59170b00-0000000000047c88-0005bb5468ab9dbc.journal (5.7M).
Deleted archived journal /run/log/journal/6bad2a7eb9f345f09607d96d90952214/system@27769cc7efce4c749e779b9d59170b00-0000000000049969-0005bb59bcc5d2e5.journal (5.7M).
Deleted archived journal /run/log/journal/6bad2a7eb9f345f09607d96d90952214/system@27769cc7efce4c749e779b9d59170b00-000000000004b672-0005bb5f31ea8b01.journal (5.7M).
Vacuuming done, freed 17.3M of archived journals from /run/log/journal/6bad2a7eb9f345f09607d96d90952214.

1 Like

I know what logs and on what device you’re talking about but not everyone will and it’s not obvious.

I think more detail about what logs, what device/os and why would be useful.

2 Likes

I agree. Suggesting any sudo command without an explanation of exactly what it will change, is very irresponsible.

There are any number of new users who might copy and paste a command just because it comes from a “reputable source”. Or worse, type it out and get part wrong, and do real damage.

(I realize that this particular command is relatively safe, but this is just a bad practice)

3 Likes

Au Contraire! I appreciate the command because I had no idea how to remove logs that were clogging the system. They removed a couple of gigabytes of “stuff” that I didn’t know existed…

The title of thread is self-explanatory.
Further explanation is in the 1st & 3rd lines of the opening post.

 

The Title says it all: “System Logs”

 

1 Like

Your arrogance is annoying at times.

If you are going to blithely supply commands that run with root access, you OWE it to the users here to explain exactly what is going to happen. Full stop.

3 Likes

Oddly I ran that command on two different Pi Zeros and both had differing uptime but both reported identical 18.9M of archived journals freed.

Coincidence or are they set sizes?

Geoff

1 Like

The files are fixed size and there’s a fixed limit on maximum history that’s set based on (essentially) a fraction of available RAM.

Which brings us to the second point, which is that manually vacuuming the journal files is basically pointless because the journal files are fixed in size and stored in RAM only (note how all the “cleaned” paths are under /run). There’s really no point in doing this. It will temporarily free a small amount of RAM (and if you’re that low on available memory, you have other problems) but then it’ll just consume the space again as it moves back towards the steady state.

5 Likes

Thanks @obj for clarification. I was not aware of this, and thought vacuuming will clear old logs accumulated over months and years and will free up substantial disk space.

1 Like

They removed a couple of gigabytes of “stuff” that I didn’t know existed"

I got 45MB of stuff