I
I
icoz2013-03-10 14:14:52
Joomla
icoz, 2013-03-10 14:14:52

How to properly clean logs in journald (systemd)

Faced with the fact that the logs /var/log/journal/began to occupy more than a gig.

$ journalctl --disk-usage 
Journals take up 1010.5M on disk.

But at the same time, it journalctldoes not contain any parameters and options that allow you to delete old entries: for example, those made before a certain date.
I rummaged through the config /etc/systemd/journald.conf- there is only about limiting the size of magazines.
I set the limit, but journalddid not cut the logs.
How to properly remove surplus?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
L
lmrvsk, 2019-03-01
@lmrvsk

To clear the logs according to the conditions: to a date or cut to such and such a size (in the number of records or in MB), you can use the built-in commands:

journalctl --vacuum-size=128M
journalctl --vacuum-time=1d

I
icoz, 2013-03-10
@icoz

At the moment, I found only an offer on the net to stupidly delete the contents of the folder /var/log/journal/.
I did not delete everything, but only the files " *.journal~".
The folder is lighter by 600M. I don't see any bugs in my work.
But cleaning according to the conditions is of interest: to a date or cut to such and such a size (in the number of records or in MB).

A
Acidter, 2017-01-22
@Acidter

On this issue, everything is well described on the Arch Wiki https://wiki.archlinux.org/index.php/Systemd_(%D0%...

Y
yazon, 2013-03-15
@yazon

Regular logrotate will not help?

Z
Zyamilon, 2014-02-18
@Zyamilon

$ pacman -Qi systemd
Название              : systemd
Версия                : 208-3
...
$ sudo systemctl start systemd-journal-flush

Description=Trigger Flushing of Journal to Persistent Storage
We check:
sudo journalctl --disk-usage

S
sur0k, 2020-03-05
@sur0k

Why not just add log cleanup to crontab?
sudo crontab -e
there we add the desired schedule and insert the cleaning command. For example:
0 0 * * * journalctl --vacuum-time=1d

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question