How to cleaning “/tmp”

I use Leap 15.4

My /TMP directory is not being cleaned and occupies 90 GB on disk. My Directory /etc/tmpfiles.d is empty.
I tried to create the file with:

cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf.

cp: Impossible to obtain information for ‘/usr/lib/tmpfiles.d/tmp.conf’: File or non -existent folder

and It’s not possible, the file tmp.conf not exist. I use btrfs, I don’t know has something to do.

Someone knows how to solve this problem.

My fstab:

UUID=5593a102-1216-453b-ae78-a53d4be7315c swap swap defaults 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a / btrfs defaults 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /.snapshots btrfs subvol=/@/.snapshots 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /var btrfs subvol=/@/var 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /usr/local btrfs subvol=/@/usr/local 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /tmp btrfs subvol=/@/tmp 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /srv btrfs subvol=/@/srv 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /root btrfs subvol=/@/root 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /opt btrfs subvol=/@/opt 0 0
UUID=7e254ce5-03ed-4e12-89a6-f3feb99ed1ad /home xfs defaults 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=7e10806d-155d-401b-80c5-59183713335a /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=725B-2856 /boot/efi vfat utf8 0 2

Thanks

Rui Pedro

This may be of value to you…
https://en.opensuse.org/SDB:Cleanup_system#Cleanup_/tmp

Indeed, I looked at my Leap 15.4 VM and found files several years old. This is intentional. From systemd spec file:

And tmp.conf is removed when package is built.

That is completely useless if this file exists and does not work if this file does not exist as you have found.

You need to decide how exactly you want to clean /tmp. Default current upstream tmp.conf is

q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d

but e.g. Ubuntu is using D /tmp ... which completely wipes out /tmp on boot. Read man tmpfiles.d for full description. SUSE installs /usr/lib/tmpfiles.d/fs-tmp.conf which just creates directorysubvolume; you can copy it into /etc/tmpfiles.d and change as you like. To match upstream default:

bor@10:~> cat /etc/tmpfiles.d/fs-tmp.conf 
q /tmp 1777 root root 10d
bor@10:~> 

Of course you can even go old school and simply create cron job for this. Or mount /tmp as tmpfs.

Tanks.

In fact in Leap the file that controls the cleaning is at /usr/lib/tmpfiles.d/fs-tmp.conf.

My fs-tmp.conf is like this:

q /tmp 1777 root root -

I will change and will test then I tell you something.

Either way I will use tmpfs. I use tmpfs on tumbleweed machines and works perfect.

Tanks

This file does not clean anything.

Well, with the ‘-’ in the position it’s in, that’s correct. But changing the ‘-’ to something like ‘1d’ would (or should, according to the manpage for tmpfiles.d.