[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to prevent /tmp files from being deleted at reboot



Michael Biebl wrote:
> Now to your issue. You said you wanted time based clean-up (remove files
> older then 30 days) but *not* remove them on boot.
> 
> You've created a file /etc/tmpfiles.d/tmp.conf which overrides the
> default that is shipped in /usr/lib/tmpfiles.d/tmp.conf
> So far so good. What you used in /etc/tmpfiles.d/tmp.conf is:
> 
> D /tmp 1777 root root 30d
> 
> Let's see the tmpfiles.d man page [1]:
> 
> >        D
> >            Similar to d, but in addition the contents of the directory will be
> >            removed when --remove is used.
> 
> During boot systemd-tmpfiles-setup.service is run:
> 
> $ systemctl cat systemd-tmpfiles-setup.service | grep ExecStart
> ExecStart=/bin/systemd-tmpfiles --create --remove --boot
> --exclude-prefix=/dev
> 
> So, you actually requested that /tmp is cleaned up during boot. What you
> want is the 'd' option. Again, have a look at the tmpfiles.d man page [2]:
> 
> >        d
> >            Create a directory. The mode and ownership will be adjusted if specified and the directory already exists. Contents of this directory are subject to time based cleanup if the time
> >            argument is specified.
> 
> 
> So, what you copied from the bug report was simply not what you were
> looking at. Always consult the man pages. The ones shipped by systemd
> are actually pretty decent.

My first mail to that bug report, at
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795269#10 , had a bug
in the patch: it migrates the TMPTIME setting to the appropriate line,
but it doesn't change 'D' to 'd', so /tmp still gets wiped on boot.  I
sent an updated patch to the bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795269#22

Please consider applying that updated patch to the systemd postinst.

- Josh Triplett


Reply to: