Description of problem:
There is a need to clean content from a directory based on age, but only if the directory exists. Filetype D in a tmpfiles.d conf file doesn't work, because it will create the directory if it doesn't exist. R doesn't use the age parameter.
Version-Release number of selected component (if applicable):
Use a tmpfiles conf of:
D /root/saplogs 755 root root 5d -
Steps to Reproduce:
1. Create a /etc/tmpfiles.d/tmpfiles conf of: "D /root/saplogs 755 root root 5d -"
2. run systemd-tmpfiles --clean
3. look at /root, there how is a subdir "saplogs"
a directory /root/saplogs exists
Propose to have the age parameter also work for r and R filetypes. This is imo backwards compatible and as such an enhancement.
What is the real use-case for this? Usually you want the directory there.
application admin installs sap components using sudo. sap leaves install logs in /root in a subdir saplog/. application admins cannot remove those because of permissions. sys admins want this directory cleaned out after x days. If the subdir saplog/ doesn't exist, nothing have to happen.
(In reply to Fred van Zwieten from comment #3)
Uh this is so wrong. User who does not have access to /root directory runs an application which writes logs to /root? At least please tell you customer to file a bug against sap to move those to /var.
Tmpfilesd is about actions which happens repeatedly, what you want to do is just plan some action to the future. Also remove actions are only bound to boot (we only call /usr/bin/systemd-tmpfiles --clean in the timer).
I spend quite a lot of time thinking about a sane use-case, but I haven't found one. I really think that introducing such possibility would lead to really bad practices like the one above.
(In reply to Lukáš Nykrýn from comment #5)
Reopening this bug as I think there is a valid use case.
> (In reply to Fred van Zwieten from comment #3)
> Uh this is so wrong. User who does not have access to /root directory runs
> an application which writes logs to /root?
You are absolutely right but there are other uses cases.
With RHEL7, systemd-tmpfiles seems to have deprecated tmpwatch. The latter is
not installed by default and for example the X11 lock files are now cleaned by
/usr/lib/tmpfiles.d/x11.conf. Lets say, the customer just wants to use the new
technology as shipped with RHEL7 to clean a file in some directory under, lets
say, /var. Though if it doesn't exists (i.e. some application did not create
the directory yet), it should not be created as part of a housekeeping job.
> Tmpfilesd is about actions which happens repeatedly, what you want to do is
> just plan some action to the future. Also remove actions are only bound to
> boot (we only call /usr/bin/systemd-tmpfiles --clean in the timer).
Yes, and when the r/R type has an age defined, they should be actioned by
--clean as well (triggered by the timer).
Hi Lukas, Appreciate your feedback on comment#6 with regards to the use case.
I believe that what Fred asks for was already implemented upstream:
fix merged to upstream staging branch ->
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.