/tmp, /var/tmp cleaned via crontab & MAX_DAYS_IN_TMP /etc/sysconfig Editor

In openSUSE 13.2 how does /tmp and /var/tmp get cleaned?

There use to be system variables MAX_DAYS_IN_TMP, etc, in YaST /etc/sysconfig Editor, but I have not been successful in seeing how it is done now.

Copy /usr/lib/tmpfiles.d/tmp.conf to /etc/tmpfiles.d and edit the file according to your needs.

You can find more information with; man tmpfiles.d

Thius is from the 12.3 Release Notes:

5.2. systemd: Cleaning Directories (/tmp and /var/tmp)

By default, systemd cleans tmp directories daily as configured in /usr/lib/tmpfiles.d/tmp.conf. Users can change it by copying /usr/lib/tmpfiles.d/tmp.conf to /etc/tmpfiles.d/tmp.conf and modifying the copied file. It will override /usr/lib/tmpfiles.d/tmp.conf.
Note: systemd does not honor obsolete sysconfig variables in /etc/sysconfig/cron such as TMP_DIRS_TO_CLEAR.

But the policy changed to NOT clean. This is from 13.1, so check on yoir 13.2:

boven:~ # cat /usr/lib/tmpfiles.d/tmp.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
# SUSE policy: we don't clean those directories
d /tmp 1777 root root -
d /var/tmp 1777 root root -

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-*
x /var/tmp/systemd-private-*
X /tmp/systemd-private-*/tmp
X /var/tmp/systemd-private-*/tmp
boven:~ # 

And this is the file I generated on my system to overwrite the default behaviour:

boven:~ # cat /etc/tmpfiles.d/tmp.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# De originele file staat in /usr/lib/tmpfiles.d/tmp.conf
# Deze copie in /etc/tmpfiles.d overschrijft dat.

# Clear tmp directories separately, to make them easier to override
# Eigen policy: maak /tmp en /var/tmp leeg.
D /tmp 1777 root root 1d
D /var/tmp 1777 root root 1d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-*
x /var/tmp/systemd-private-*
X /tmp/systemd-private-*/tmp
X /var/tmp/systemd-private-*/tmp
boven:~ # 

The differences between the two:

boven:~ # diff /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf 
9a10,12
> # De originele file staat in /usr/lib/tmpfiles.d/tmp.conf
> # Deze copie in /etc/tmpfiles.d overschrijft dat.
> 
11,13c14,16
< # SUSE policy: we don't clean those directories
< d /tmp 1777 root root -
< d /var/tmp 1777 root root -
---
> # Eigen policy: maak /tmp en /var/tmp leeg.
> D /tmp 1777 root root 1d
> D /var/tmp 1777 root root 1d
boven:~ #

Since openSUSE 12.3

By default, systemd cleans tmp directories daily as configured in /usr/lib/tmpfiles.d/tmp.conf

Users can change it by copying /usr/lib/tmpfiles.d/tmp.conf to /etc/tmpfiles.d/tmp.conf and modifying the copied file.

It will override /usr/lib/tmpfiles.d/tmp.conf.

Note: systemd does not honor obsolete sysconfig variables in /etc/sysconfig/cron such as TMP_DIRS_TO_CLEAR.

Clear tmp directories separately, to make them easier to override

SUSE policy: we don’t clean those directories

d /tmp 1777 root root -
d /var/tmp 1777 root root -

Before I guess it used to be 10d, wonder why they changed.
Might not good for new user that are not aware.

I will do the copy and read the man page. My productive system is much older, so I’ll have to read all those RELEASE NOTES. Hope they are still online.

I have been doing reading and note taking, this was a particularlly interesting bug report, 860067 - “Systemd does not clear temporary files from /tmp and /var/tmp daily” and 908162. It seems folks are having a hard time these days even agreeing on what constitutes a tmp directory. Argh. Are we following FHS these days, or no?

3.17. /tmp : Temporary files
3.17.1. Purpose
The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the
program. ~FHS_2.3

My pre-install and testing is not going as easily as past installs. I am busy fixing things as I run across them.

Thank you.

Nineteen years ago ago (running slackware at that time), I had some files in “/tmp” because I had not decided on a permanent place for them. The stayed in “/tmp” for around 5 years or more. If it’s your system, then “tmp” is what you want it to be.

These days I’m a tad more organized, so I use “$HOME/tmp” for files that I haven’t decided where to permanently put them or whether to permanently keep them.