TransWikia.com

Create a persistent temp directory with temporary content

Unix & Linux Asked on November 23, 2021

I wish to create a directory in $TMP_DIR or /tmp/ which persists forever (i.e. is never deleted) but it is maintained by OS, i.e. the content of which can be deleted if they have not been opened/used in a while or system needs more space.

Essentially directory to put random temporary stuff in and forget about maintaning it, but not having to recreate this directory anytime I want to use it and it’s path doesn’t change so scripts/application can use it.

What is the best way to achieve this?

I can see in /etc/default/periodic.conf there’re these options:

# 110.clean-tmps
daily_clean_tmps_enable="YES"               # Delete stuff daily
daily_clean_tmps_dirs="/tmp"                # Delete under here
daily_clean_tmps_days="3"               # If not accessed for
daily_clean_tmps_ignore=".X*-lock .X11-unix .ICE-unix .font-unix .XIM-unix"
daily_clean_tmps_ignore="$daily_clean_tmps_ignore quota.user quota.group"   # Don't delete these
daily_clean_tmps_verbose="YES"              # Mention files deleted

Can I add a path to daily_clean_tmps_ignore e.g. ...="my-persistant-unique-dir and it will respect it?

One Answer

Essentially directory to put random temporary stuff in and forget about maintaning it, but not having to recreate this directory anytime I want to use it and it's path doesn't change so scripts/application can use it.

You want /var/tmp for that. It is system-maintained, always there (unless you remove it), doesn't get cleaned (unless you configure that) and the path is stable. The FHS has more details.

Answered by eleventyone on November 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP