I'm trying to manage a new tempdir with systemd-tmpfiles, but I
can't find a set of directives that do what I expect.
I'm obviously missing something, as there's plenty of documentation
out there, but I can't achieve the desired effect.
My environment is SLES12SP6, running systemd 228.
Some more specifics:
I have a new user and group, with a tmp directory with the sticky
bit set:
10-153-68-12:~ # groupadd foobar
10-153-68-12:~ # useradd -g foobar -m -d /home/foobar foobar
10-153-68-12:~ # mkdir -p /home/foobar/tmp
10-153-68-12:~ # chmod 1700 /home/foobar/tmp
10-153-68-12:~ # ls -ld --full-time /home/foobar/tmp
drwx-----T 2 foobar foobar 4096 2025-01-30 17:47:52.398749507 -0500
/home/foobar/tmp
I then create 45 days of historical files in that temp directory:
10-153-68-12:~ # start=$( date +%Y-%m-%d ); count=45; while (( --count >=
0)); do curr=$(date +%Y-%m-%d --date "${start} -${count} day"); touch -d
"${curr}" "/home/foobar/tmp/example.${curr}"; done
10-153-68-12:~ # chown -R foobar:foobar /home/foobar
Just to show I have 45 old files:
10-153-68-12:~ # ls -ldtr --full-time /home/foobar/tmp/example.* | head -1
-rw-r--r-- 1 foobar foobar 0 2024-12-16 00:00:00.000000000 -0500
/home/foobar/tmp/example.2024-12-16
10-153-68-12:~ # ls -ldtr --full-time /home/foobar/tmp/example.* | wc -l
45
Now, let's describe a config file for systemd-tmpfiles, with the
goal of scrubbing files older than 10 days:
10-153-68-12:~ # echo 'q /home/foobar/tmp 1700 foobar foobar 10d' >
/usr/lib/tmpfiles.d/foobar.conf
My expectation is that this would perform that cleanup pass. Pardon
the noise, SLES's packaging is sloppy:
10-153-68-12:~ # systemd-tmpfiles --remove --clean
[/usr/lib/tmpfiles.d/dirmngr.conf:1] Line references path below legacy
directory /var/run/, updating /var/run/dirmngr ??? /run/dirmngr;
please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/screen.conf:2] Line references path below legacy
directory /var/run/, updating /var/run/screens ??? /run/screens;
please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/screen.conf:3] Line references path below legacy
directory /var/run/, updating /var/run/uscreens ??? /run/uscreens;
please update the tmpfiles.d/ drop-in file accordingly.
But, no files have been clean out:
10-153-68-12:~ # ls -ldtr --full-time /home/foobar/tmp/example.* | wc -l
45
So, what did I do wrong?
I'm happy for any guidance anyone can provide.
--
Brian Reichert <[email protected]>
BSD admin/developer at large