You are not logged in.

#1 2025-01-21 01:43:47

odror
Member
Registered: 2015-03-17
Posts: 146

[solved] /var/tmp is not clearing files older than 30 days

I am using the Default settings.

systemd-tmpfiles-clean.timer is active

and
systemd-tmpfiles-clean

is running as scheduled, but old files are not cleared from /var/tmp. In particular older files in sub-directories of /var/tmp/  are not being cleaned. I have files from April that have not been cleared

Any additional setup that I need.

Last edited by odror (2025-01-29 01:19:12)

Offline

#2 2025-01-21 23:07:27

seth
Member
Registered: 2012-09-03
Posts: 60,828

Re: [solved] /var/tmp is not clearing files older than 30 days

grep -rE '^[dDe].*var' /etc/tmpfiles.d/* /run/tmpfiles.d/* /usr/local/lib/tmpfiles.d/* /usr/lib/tmpfiles.d/* /usr/local/share/user-tmpfiles.d/*  /usr/share/user-tmpfiles.d/*
grep -rE 'var/tmp' /etc/tmpfiles.d/* /run/tmpfiles.d/* /usr/local/lib/tmpfiles.d/* /usr/lib/tmpfiles.d/* /usr/local/share/user-tmpfiles.d/*  /usr/share/user-tmpfiles.d/*
man 5 tmpfiles.d

Offline

#3 2025-01-24 20:02:25

mountaintrek
Member
Registered: 2024-02-01
Posts: 40

Re: [solved] /var/tmp is not clearing files older than 30 days

Check the console output from:

env SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --clean

Offline

#4 2025-01-26 00:13:36

odror
Member
Registered: 2015-03-17
Posts: 146

Re: [solved] /var/tmp is not clearing files older than 30 days

I think I found the issue. I have a directory in /var/scan where I want to keep files up to 30 days. The issue is that systemd check the 30 days limit by access time and not by creation time. So whenever I use nautilus on this directory, it resets the access time for every file in the directory.

I need files to be deleted based on creation time and not access time.

my conf file in /etc/tmpfiles.d is

v /var/tmp/scan - root root 30d

Offline

#5 2025-01-26 01:05:59

seth
Member
Registered: 2012-09-03
Posts: 60,828

Re: [solved] /var/tmp is not clearing files older than 30 days

man 5 tmpfiles.d wrote:

       The age of a file system entry is determined from its last modification timestamp (mtime),
       its last access timestamp (atime), and (except for directories) its last status change
       timestamp (ctime). By default, any of these three (or two) values will prevent cleanup if it
       is more recent than the current time minus the age field. To restrict the deletion based on
       particular type of file timestamps, the age-by argument can be used.

Offline

#6 2025-01-26 03:25:37

mpan
Member
Registered: 2012-08-01
Posts: 1,367
Website

Re: [solved] /var/tmp is not clearing files older than 30 days

(I am wrong, see seth below) But that begs the question: why is access time updated? The default is relatime. With very few exceptions it should stay this way. Why is the mount point configured different on your system?

Last edited by mpan (2025-01-26 16:34:35)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#7 2025-01-26 10:20:14

seth
Member
Registered: 2012-09-03
Posts: 60,828

Re: [solved] /var/tmp is not clearing files older than 30 days

man mount wrote:

       relatime
           Update inode access times relative to modify or change time. Access time is only updated
           if the previous access time was earlier than or equal to the current modify or change
           time. (Similar to noatime, but it doesn’t break mutt(1) or other applications that need
           to know if a file has been read since the last time it was modified.)

           Since Linux 2.6.30, the kernel defaults to the behavior provided by this option (unless
           noatime was specified), and the strictatime option is required to obtain traditional
           semantics. In addition, since Linux 2.6.30, the file’s last access time is always
           updated if it is more than 1 day old.

(Ftr, I know that because I held the same misbelief)

Offline

#8 2025-01-26 16:33:54

mpan
Member
Registered: 2012-08-01
Posts: 1,367
Website

Re: [solved] /var/tmp is not clearing files older than 30 days

TIL. Thanks, seth!

/me slaps himself for not checking the source he linked. neutral


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#9 2025-01-29 01:17:51

odror
Member
Registered: 2015-03-17
Posts: 146

Re: [solved] /var/tmp is not clearing files older than 30 days

Problem fixed. I changed the line in he file in /tmp/tmpfiles.d

to

v /var/tmp/scan - root root bmBM:30d

Offline

Board footer

Powered by FluxBB