I'm trying to change the cleanup interval for Apache PrivateTmp files from the default 30 days to 6 hours. I read that to edit the time intervals, I should set up an override file in /etc/tmpfiles.d/tmp.conf
rather than editing /usr/lib/tmpfiles.d/tmp.conf
, so I created that file with the following lines:
# override the default cleanup intervals
v /tmp 1777 root root 6h
v /var/tmp 1777 root root 6h
Now if I run systemd-tmpfiles --clean
, the expected files are removed, so this part is working.
However, /usr/lib/systemd/system/systemd-tmpfiles-clean.timer
has OnUnitActiveSec
set to 1d. I assume this means my 6 hour cleanup interval will effectively be limited to once per day.
I can change that timer interval to 6h or less, but should I edit this file directly, or create an override file similar to /etc/tmpfiles.d
?
Update: this question was marked as a duplicate, but I don't see anything in the linked question about whether I should be using an override file like with the tmp.conf
file.
Solution: apparently I can't post this as an answer since the question has been marked as a duplicate. But this is how I created an override file to change the timer interval:
Copy the existing timer file to the corresponding override directory:
sudo cp /usr/lib/systemd/system/systemd-tmpfiles-clean.timer /etc/systemd/system
Edit the new copy (change the 1d value to 1h):
sudo nano /etc/systemd/system/systemd-tmpfiles-clean.timer
Load the new timer file:
sudo systemctl daemon-reload
Confirm that the new timer interval is loaded:
sudo systemctl list-timers
/usr/lib/tmpfiles.d/tmp.conf
and instead use override files?systemctl edit
)..timer
files follow the same principle, or should those just be edited directly? I haven't found any documentation or examples of changing the timer values, except the "duplicate" question above, which doesn't explain where the files are located.systemctl edit
on the timer and see what happens.