0

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?

7
  • 3
    Why can't you use any other directory instead? E.g. /forevertmp ? Jul 22, 2020 at 10:51
  • What is your goal?: Tell us what you are trying to achieve. Jul 22, 2020 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, 2020 at 14:34
  • 1
    Your desire is so convoluted I just don't understand it. Your want something permanently temporary. Jul 22, 2020 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. Jul 22, 2020 at 19:04

1 Answer 1

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.

3
  • 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, 2020 at 14:31
  • You already identified how to configure it in your question. Aug 15, 2020 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, 2020 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.