I also found this very confusing. Here's a quick example. I think x versus X becomes useful if you have a deep tree inside a particular directory and you want to delete some and not all directories.
Here's my exclude.conf:
root# cat /etc/tmpfiles.d/exclude.conf
d /tmp/testdir 0755 root root 1s
x /tmp/testdir/*
Now, I create some directories:
# mkdir /tmp/testdir/a ; mkdir /tmp/testdir/b; mkdir /tmp/testdir/ab
# ls -lrt /tmp/testdir/
total 0
drwxr-xr-x. 2 root root 6 Sep 1 12:55 a
drwxr-xr-x. 2 root root 6 Sep 1 12:55 b
drwxr-xr-x. 2 root root 6 Sep 1 12:55 ab
Run clean
#systemd-tmpfiles --clean exclude.conf
Check
# ls -lrt /tmp/testdir
total 0
drwxr-xr-x. 2 root root 6 Sep 1 12:55 a
drwxr-xr-x. 2 root root 6 Sep 1 12:55 b
drwxr-xr-x. 2 root root 6 Sep 1 12:55 ab
Now, if do X /tmp/testdir/*
, I get the same result. Then, if I have x /tmp/testdir/b
, then it excludes the 'b' directory from the cleanup.
#systemd-tmpfiles --clean exclude.conf
# ls -lrt /tmp/testdir/
total 0
drwxr-xr-x. 2 root root 6 Sep 1 12:55 b
Also, X /tmp/testdir/b
shows the same behavior. However, X /tmp/testdir/
and x /tmp/testdir
will delete all the sub directories inside testdir
but will keep testdir
.
I would suggest to test the settings before you put it in place. I the man page could be little more clearer.