0

I'm writing a Python script which performs creates and modifies several files in a directory specified by the user. As part of the process, my script will download and build a toolchain used by my script. A few of the tools will need to be built and added to the PATH environment variable so my script as well as the entire toolchain itself can execute them. Once my script is complete, the toolchain will not be needed and should be discarded.

I considered creating a temporary directory for the toolchain either in the working directory or at the user's home folder and deleting it when my script completes. Unfortunately, the user may want to rerun my script which would incur the expense of downloading and rebuilding the toolchain again. I could instruct the user to delete them when they're sure they're done with my script, but I prefer a more elegant solution.

What the best practice for such a scenario in UNIX? I figure there must be a standard location UNIX uses for temporary files where they are periodically purged. It would be great if it worked across the different flavors of UNIX few, if any, modifications.

1
  • 3
    Why "should" the toolchain be discarded ? Would parts of the whole process (including the build of the toolchain) need to be run as root ? Would the toolchain (to be built) be some sort of cross-dev toolchain ( tools' names potentially conflicting with the running system's toolchain ) ? Commented Sep 1, 2022 at 7:52

1 Answer 1

0
  • Linux is using /tmp as the main temporary directory. Its content is cleaned at boot (and reboot).

  • Another temporary directory, /var/tmp, is not cleaned as often as /tmp.

  • There is also the environment variable TMPDIR.

  • See more details at this link to 'Superuser'.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.