A propos de /var/tmp

Salut
Je n’arrivai plus à faire “apt update” car le disque est plein
Je m’aperçois que /var/tmp occupe pratiquement 20% de mes 9 Gb surtout à cause d’audacity d’ailleurs.
j’ai choisi la méthode Attila et j’ai tout supprimé sans dommages apparent.
N’y a t-il pas un outil qui nettoierai périodiquement /var/tmp?

ok j’ai trouvé le paquet tmpreaper
pour l’instant je pars avec ça

root@debian:/etc# cat tmpreaper.conf
# tmpreaper.conf
# - local configuration for tmpreaper's daily run
#
# This is only used if /etc/cron.daily/tmpreaper was also updated,
# i.e. there's a line ". /etc/tmpreaper.conf" in that file.
# The shell code that used to be here (pre version 1.6.7) is now
# in the cron.daily script.

# Remove the next line if you understand the possible security implications of
# having tmpreaper run automatically;
# see /usr/share/doc/tmpreaper/README.security.gz

SHOWWARNING=false

# TMPREAPER_TIME
#       is the max. age of files before they're removed.
#       default:
#       the TMPTIME value in /etc/default/rcS if it's there, else
#       TMPREAPER_TIME=7d (for 7 days)
#       I recommend setting the value in /etc/default/rcS, as
#       that is used to clean out /tmp whenever the system is booted.
#
# TMPREAPER_PROTECT_EXTRA
#       are extra patterns that you may want to protect.
#       Example:
#       TMPREAPER_PROTECT_EXTRA='/tmp/isdnctrl* /tmp/important*'
#
# TMPREAPER_DIRS
#       are the directories to clean up.
#       *never* supply / here! That will wipe most of your system!
#       Example:
#       TMPREAPER_DIRS='/tmp/. /var/tmp/.'
#
# TMPREAPER_DELAY
#       defines the maximum (randomized) delay before starting processing.
#       See the manpage entry for --delay. Default is 256.
#       Example:
#       TMPREAPER_DELAY='256'
#
# TMPREAPER_ADDITIONALOPTIONS
#       extra options that are passed to tmpreaper, e.g. --all

# uncomment and change the next line to overrule the /etc/default/rcS value
TMPREAPER_TIME=7d

TMPREAPER_PROTECT_EXTRA=''
TMPREAPER_DIRS='/var/tmp/.'
TMPREAPER_DELAY='256'
TMPREAPER_ADDITIONALOPTIONS=''


/var/tmp$ ls -alrt
total 20
drwxr-xr-x 11 root root 4096 juin  29 18:21 ..
drwx------  3 root root 4096 oct.   9 23:29 systemd-private-95eae66bbab54f028ffb0df5d70f7984-systemd-timesyncd.service-tkhwF4
drwx------  3 root root 4096 oct.   9 23:29 systemd-private-95eae66bbab54f028ffb0df5d70f7984-colord.service-7ZucsJ
drwx------  3 root root 4096 oct.   9 23:29 systemd-private-95eae66bbab54f028ffb0df5d70f7984-rtkit-daemon.service-HvjS50
drwxrwxrwt  5 root root 4096 oct.   9 23:33 .
1 J'aime

Sinon, tu as ma méthode sale de mettre /var/tmp dans un tmpfs.

les répertoires /temp et /run peuvent être dans un tempfs car on considère que à l’extinction de la machine tout est effacé. Pour /var/tmp par contre il est possible de conserver des informations de manière persistantes, mais pas permanente.
Le paquet «tmpreaper» est une bonne solution en effet.

Exactement. Et la j’ai retrouvé de l’oxygene

 df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1,8G     0  1,8G   0% /dev
tmpfs           370M  6,1M  364M   2% /run
/dev/sda1       9,1G  6,8G  1,8G  80% /
tmpfs           1,9G   17M  1,8G   1% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           1,9G     0  1,9G   0% /sys/fs/cgroup
tmpfs           1,9G   12K  1,9G   1% /tmp
/dev/sda6       263G   84G  166G  34% /home
tmpfs           370M  4,0K  370M   1% /run/user/118
tmpfs           370M   12K  370M   1% /run/user/1001

Il ne me reste qu’a attendre les 7 jours pour vérifier que les fichiers du 9 octobre sont bien supprimés

Juste pour info, en terme de sécurité, il était recommandé certaines choses à-propos …

De lier /var/tmp, avec /tmp … et d’utiliser les options de montage ‘nodev,noexec,nosuid’.

J’en parle plus en détail sur mon blog

Avec systemd on active un service
https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems/

systemctl start tmp.mount

systemctl list-unit-files --type=mount
UNIT FILE                     STATE    
-.mount                       generated
dev-hugepages.mount           static   
dev-mqueue.mount              static   
home.mount                    generated
media-cdrom0.mount            generated
proc-sys-fs-binfmt_misc.mount static   
sys-fs-fuse-connections.mount static   
sys-kernel-config.mount       static   
sys-kernel-debug.mount        static   
tmp.mount                     enabled  

10 unit files listed.

Rien dans ma fstab .

debian:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1,8G     0  1,8G   0% /dev
tmpfs           370M  6,0M  364M   2% /run
/dev/sda1       9,1G  6,9G  1,8G  80% /
tmpfs           1,9G   36M  1,8G   2% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           1,9G     0  1,9G   0% /sys/fs/cgroup
tmpfs           1,9G  8,0K  1,9G   1% /tmp
/dev/sda6       263G   85G  165G  34% /home
tmpfs           370M  4,0K  370M   1% /run/user/118
tmpfs           370M   12K  370M   1% /run/user/1001

ça se configure https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html mais là c’est un peu trop pour moi :grinning:

1 J'aime

Merci pour l’info … je regarderais cela quand j’aurais un peu plus de temps …

Soit disant, c’est pour faciliter la vie systemd … moi, pas avoir tout compris !

Tout ça fonctionne très bien, plus de vieilleries dans /var/tmp

root@debian:/# ls -alrt /var/tmp
total 32
drwxr-xr-x 11 root root 4096 juin  29 18:21 ..
drwx------  3 root root 4096 oct.  17 10:39 systemd-private-425b32ab07d341329ca8f5a02bf8c915-systemd-timesyncd.service-z26TaC
drwx------  3 root root 4096 oct.  17 10:39 systemd-private-425b32ab07d341329ca8f5a02bf8c915-colord.service-BM9MwD
drwx------  3 root root 4096 oct.  17 10:40 systemd-private-425b32ab07d341329ca8f5a02bf8c915-rtkit-daemon.service-QP23Yk
drwx------  3 root root 4096 oct.  21 10:41 systemd-private-25d169d0390d4a79ae38ed8f9a48648e-systemd-timesyncd.service-hM00qU
drwx------  3 root root 4096 oct.  21 10:41 systemd-private-25d169d0390d4a79ae38ed8f9a48648e-colord.service-Q0be8i
drwx------  3 root root 4096 oct.  21 10:42 systemd-private-25d169d0390d4a79ae38ed8f9a48648e-rtkit-daemon.service-0Jhlb2
drwxrwxrwt  8 root root 4096 oct.  21 12:40 .
root@debian:/#