How to autmatically remove journal tilde files

I find files like this (with a tilde at the end):

rw-r-----  root     systemd-journal  64.0M 12/31/2022 10:03:10 /var/log/journal/6cca42653c544214ab0cf5d8f190511e/system@0005f12389397127-618c556b462310b7.journal~

How can i setup something, like say logrotate, or some other means, to just delete those when they are created.

@erbenton you can configure via editing /etc/systemd/journald.conf, but read the man page man journald.conf` as there are many ways to configure. I does cap the limit in this directory to 4G and will auto remove.

I just checked one TW installation and found 3 files ending in ~. They were the oldest there, more than a year old. I deleted all.

@mrmazda you should really use the journal tools to rotate and clean…

journalctl --disk-usage

Archived and active journals take up 3.9G in the file system.

journalctl --flush --rotate

journalctl --vacuum-time=30d

journalctl --disk-usage

Archived and active journals take up 193.5M in the file system.

I would configure the journal config to set your limits.

I would think that things like journal and smartmon tools, and others, would clean up after themselves and remove the tilde files. Somebody ought to poke them and say “Hey cleanup after yourselves”
Try running this (if you have mlocate installed)
/usr/bin/updatedb --verbose --prunepaths="/mnt /proc /dev /sys"|grep -E "~$"

On my system just now I have this:

rw-r--r--  root     root    1.8K 01/08/2023 03:09:55 /var/lib/smartmontools/smartd.KINGSTON_SH103S390G-50026B7223029812.ata.state~
rw-r--r--  root     root    1.7K 12/11/2022 18:06:33 /var/lib/smartmontools/smartd.OCZ_VERTEX_v1_10-CK1S2N8W043Z1S7SV94P.ata.state~
rw-r--r--  root     root    2.5K 01/07/2023 03:09:58 /var/lib/smartmontools/smartd.ST1000LM024_HN_M101MBB-S30YJ9HF807811.ata.state~
rw-r--r--  root     root    2.8K 01/08/2023 06:39:54 /var/lib/smartmontools/smartd.ST4000VN008_2DR166-ZDH9HVA2.ata.state~
rw-r--r--  root     root    2.8K 01/08/2023 06:39:54 /var/lib/smartmontools/smartd.ST4000VN008_2DR166-ZGY8YKN4.ata.state~
rw-r--r--  root     root    1.6K 01/08/2023 03:09:55 /var/lib/smartmontools/smartd.Samsung_SSD_850_PRO_256GB-S1SUNSAF939130Z.ata.state~
rw-r--r--  root     root    1.6K 01/08/2023 06:09:59 /var/lib/smartmontools/smartd.Samsung_SSD_860_EVO_1TB-S3Z8NB0K508022L.ata.state~
rw-r--r--  root     root    1.7K 12/16/2022 15:36:58 /var/lib/smartmontools/smartd.Samsung_SSD_870_EVO_500GB-S6PXNM0T808002X.ata.state~
rw-r--r--  root     root      86 01/03/2023 16:03:52 /var/lib/smartmontools/smartd.Samsung_SSD_970_EVO_Plus_500GB-S58SNMFNA35505X.nvme.state~
rw-r--r--  root     root    1.9K 01/08/2023 06:09:59 /var/lib/smartmontools/smartd.WDC_WD40EZRZ_22GXCB0-WD_WCC7K3TN1SXX.ata.state~
rw-r--r--  root     root    1.9K 01/08/2023 03:09:55 /var/lib/smartmontools/smartd.WDC_WD40NDZW_11MR8S1-WD_WXB1E993SYP5.ata.state~
rw-r--r--  root     root    1.9K 01/08/2023 06:09:59 /var/lib/smartmontools/smartd.WDC_WD5000BMVW_11AMCS0-WD_WX91A61A6442.ata.state~
rw-r--r--  root     root    4.9K 08/24/2022 17:26:17 /var/tmp/zypp.V3hC4R/zypp-trusted-kr5HFmJH/pubring.kbx~
rw-r--r--  root     root    6.2K 12/27/2022 16:22:06 /var/tmp/zypp.hG52yg/zypp-trusted-krRHmrtA/pubring.kbx~
rw-r--r--  root     root    4.9K 08/24/2022 15:03:23 /var/tmp/zypp.kc9DOT/zypp-trusted-kroKoAdn/pubring.kbx~

@erbenton the journals clean up, 4G is the default max size, there is an expectation that end users configure their system as they require, same with the likes of folks who use sudo.

I was simply commenting that tilde files are just files like any of the others there, and ancient ones ones aren’t really distinctive.

# ls -gG /etc/systemd/journald.conf
-rw-r--r-- 1 1273 Aug 30 18:26 /etc/systemd/journald.conf
# grep -v ^# /etc/systemd/journald.conf

[Journal]
SystemMaxFiles=10
RuntimeMaxFiles=12
ForwardToConsole=yes
TTYPath=/dev/tty10
Audit=no