1

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?

user14492
  • 853
  • 3
    Why can't you use any other directory instead? E.g. /forevertmp ? – Artem S. Tashkinov Jul 22 '20 at 10:51
  • What is your goal?: Tell us what you are trying to achieve. – ctrl-alt-delor Jul 22 '20 at 11:16
  • @ArtemS.Tashkinov because I don't want to remove things when they haven't been used and when system is running out of space... "Essentially directory to put random temporary stuff in and forget about it..." Please read the whole question. – user14492 Jul 22 '20 at 14:34
  • 1
    Your desire is so convoluted I just don't understand it. Your want something permanently temporary. – Artem S. Tashkinov Jul 22 '20 at 14:42
  • What is your goal? Not what mechanism are you trying to achieve. But what is your goal? Give us some use cases. Help us to see why. Then we can suggest what you could do. At present the question body does not have enough information. We could guess (like @ArtemS.Tashkinov did, and get shot down), but there are so many possibilities. – ctrl-alt-delor Jul 22 '20 at 19:04
  • Do you want files to ever be automatically removed? If so when? – ctrl-alt-delor Jul 22 '20 at 19:08
  • @user14492 Your dir is either persistent which means that you will have to delete stuff when you are running out of space or it's not persistent. It it's impossible to magically remember your files after a reboot without using disk space. – Garo Jul 23 '20 at 00:28

1 Answers1

0

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.

  • How can I configure that when it is cleaned? How can I create a child dir that path that is persistent but it's content can be removed? – user14492 Aug 12 '20 at 14:31
  • You already identified how to configure it in your question. – eleventyone Aug 15 '20 at 12:13
  • /etc/default/periodic.conf ? Is there a manual page for this? Need more info before feeling conformable to change it. – user14492 Aug 17 '20 at 12:39
  • Having worked as a sysadmin for a long time, I don't like the idea of a volatile /tmp as /tmp can have useful information, e.g. after a system crash or a security attack. Thus, I always make it a persistent directory and add housekeeping to it. – user333869 Nov 30 '22 at 08:35