Skip to content

Making journalctl delete log entries older than a given date - how to do it

Question: How to make journalctl trim entries older than a certain date

My problem:

journalctl does not seem to trim journals as it should.

My environment: Up to date Archlinux 64bit on Thinkpad

What I have tried:

Reading the info page on systemctl journalctl, and ran this:

[root@archover ~]# journalctl --vacuum-time=4days
Vacuuming done, freed 0B of archived journals from /var/log/journal/2cfd9dec960b4861aecb88a76fc32810.

Which, i believe, shows nothing to do since i executed that command just a few minutes ago.

Yet, when I run this:

journalctl 

It returns entries from June 2016 and newer

If it helps, here's more data points:

[root@archover ~]# journalctl --disk-usage
Archived and active journals take up 80.0M in the file system.


journalctl --list-boots
#lists boots from months ago

How do I actually trim my journal entries to just 4 days ago? (4 days is arbitrary)

Thanks in advance.

Edited 30 Mar 2017. We only hold this version.

5 points4 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
5 · 100% up
Kind
Text
ID
62gesf

Author

33
posts
7.2k
comments
1
media
View profile

4 comments

odd. should work as you're doing it.

assuming you got output the first time on --vacuum-time.

file + sizes in /var/log/journal/2cfd9dec960b4861aecb88a76fc32810 shed some light? or do you have any wierd journald.conf settings?

vacuum won't destroy the active journal, so if that extends beyond $time, you will have that stuff - but that would be wierd anyway, because the active journal shouldnt go back too far, and even so 80MB for all the way back to june 2016 is pretty skimpy.

1 points

UPDATE moved the user-1000* files and now journalctl reports from March 23 to March 30, which is good enough for me. Of course, it's still not just 4 days...

Here's the files in the journal directory 2cf...

[root@archover 2cfd9dec960b4861aecb88a76fc32810]# ls -lh

total 81M

-rw-r-----+ 1 root systemd-journal  32M Mar 30 23:02 system.journal

-rw-r-----+ 1 root systemd-journal  24M Mar 30 23:08 user-1000.journal

-rw-r-----+ 1 root systemd-journal 8.0M Jun 22  2016 user-1001.journal

-rw-r-----+ 1 root systemd-journal 8.0M Jul 11  2016 user-1002.journal

-rw-r-----+ 1 root systemd-journal 8.0M Jan 13 16:59 user-1003.journal

Do those files look something like yours?

or do you have any wierd journald.conf settings?

I've never modified it and every line is commented out as I believe it is using defaults.

Would you be willing to try to vacuum some lines to see if that works for you as expected?

Thanks

1 points

Would you be willing to try to vacuum some lines to see if that works for you as expected?

yup, works, even tried 1m on my desktop - removed all but active journals (about a days worth in my case).

Here's the files in the journal directory 2cf...

that all looks fine - just your active journals(as they stretch back to the 23), vacuum wont touch them.

it's still strange that --- ooo you know what, maybe. maybe one of those users doesn't login often? and their active journal could go all the way back to june2016. and why moving those journal file 'fixed' the issue.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.