151 points

Cleanup

Check current disk usage:

sudo journalctl --disk-usage

Use rotate function:

sudo journalctl --rotate

Or

Remove all logs and keep the last 2 days:

sudo journalctl --vacuum-time=2days

Or

Remove all logs and only keep the last 100MB:

sudo journalctl --vacuum-size=100M

How to read logs:

Follow specific log for a service:

sudo journalctl -fu SERVICE

Show extended log info and print the last lines of a service:

sudo journalctl -xeu SERVICE

permalink
report
reply
38 points

I mean yeah -fu stands for “follow unit” but its also a nice coincidence when it comes to debugging that particular service.

permalink
report
parent
reply
4 points

😂😂

permalink
report
parent
reply
23 points

--vacuum-time=2days

this implies i keep an operating system installed for that long

permalink
report
parent
reply
9 points

something something nix?

permalink
report
parent
reply
19 points

sudo journalctl --disk-usage

panda@Panda:~$ sudo journalctl --disk-usage  
No journal files were found.  
Archived and active journals take up 0B in the file system.

hmmmmmm…

permalink
report
parent
reply
12 points
*
user@u9310x-Slack:~$ sudo journalctl --disk-usage  
Password:  
sudo: journalctl: command not found  
permalink
report
parent
reply
20 points
*

seems like someone doesn’t like systemd :)

permalink
report
parent
reply
5 points

I don’t have any feelings towards particular init systems.

permalink
report
parent
reply
9 points

Badass! Thanks!

permalink
report
parent
reply
8 points

Thank you for this, wise sage.

Your wisdom will be passed down the family line for generations about managing machine logs.

permalink
report
parent
reply
5 points

Glad to help your family, share this wisdom with friends too ☝🏻😃

permalink
report
parent
reply
1 point

Yeah, if I had dependents they’d gather round the campfire chanting these mystical runes in the husk of our fallen society

permalink
report
parent
reply
6 points

@RemindMe@programming.dev 6 months

permalink
report
parent
reply
2 points

@ategon@programming.dev is the remindme bot offline?

permalink
report
parent
reply
3 points
*

Its semi broken currently and also functions on a whitelist with this community not being on the whitelist

permalink
report
parent
reply
3 points

Actually something I never dug into. But does logrotate no longer work? I have a bunch of disk space these days so I would not notice large log files

permalink
report
parent
reply
2 points
*

If logrotate doesn’t work, than use this as a cronjob via sudo crontab -e Put this line at the end of the file:

0 0 * * * journalctl --vacuum-size=1G >/dev/null 2>&1

Everyday the logs will be trimmed to 1GB. Usually the logs are trimmed automatically at 4GB, but sometimes this does not work

permalink
report
parent
reply
5 points

If we’re using systemd already, why not a timer?

permalink
report
parent
reply
3 points

If you use OpenRC you can just delete a couple files

permalink
report
parent
reply
2 points

Why isn’t it configured like that by default?

permalink
report
parent
reply
5 points

It is. The defaults are a little bit more lenient, but it shouldn’t gobble up 80 GB of storage.

permalink
report
parent
reply
2 points

Good question, it may depend on the distro afaik

permalink
report
parent
reply
31 points

Try 60GB of system logs after 15 minutes of use. My old laptop’s wifi card worked just fine, but spammed the error log with some corrected error. Adding pci=noaer to grub config fixed it.

permalink
report
reply
24 points

I had an issue on my PC (assuming faulty graphics driver or bug after waking from sleep) that caused my syslog file to reach 500GiB. Yes, 500GiB.

permalink
report
parent
reply
10 points
*

Nearly 700gb in logs

wtf 🤯

permalink
report
parent
reply
1 point

Yeah I was confused as to where all of my storage went xD

permalink
report
parent
reply
30 points

You just need a bigger drive. Don’t delete anything

permalink
report
reply
10 points

Oh lord watch me hoard

permalink
report
parent
reply
29 points
*

*cough*80 GiB*cough*

permalink
report
reply
5 points

11.6 mega bites

permalink
report
parent
reply
5 points

Ah, yes, the standard burger size.

permalink
report
parent
reply
25 points
*

Once I had a mission critical service crash because the disk got full, turns out there was a typo on the logrotate config and as a result the logs were not being cleaned up at all.

edit: I should add that I used the commands shared in this post to free up space and bring the service back up

permalink
report
reply

linuxmemes

!linuxmemes@lemmy.world

Create post

I use Arch btw


Sister communities:
Community rules
  1. Follow the site-wide rules and code of conduct
  2. Be civil
  3. Post Linux-related content
  4. No recent reposts

Please report posts and comments that break these rules!

Community stats

  • 7.3K

    Monthly active users

  • 1.2K

    Posts

  • 65K

    Comments