linux – What is the deletion logic for the / tmp folder?

Question: Question:

You may write a script that uses the /tmp folder in a shell script or the like.
Are the files in the tmp folder subject to regular deletion?

In that case, what is the standard for deletion?

I don't want the script to behave strangely due to unintentional deletion, so I'm asking. For example, if the operation is empty at a certain time and a script that uses the /tmp folder is running at that time, the operation will be strange.

Answer: Answer:

It depends on the distribution defaults and administrator settings. However, most of the time, I think that the logic is "Delete at (re) startup" and "Delete files that have not been updated for more than ○ days regularly". It should not be set so that temporary files that are created and a few minutes are erased.

By the way, POSIX and FHS (Filesystem Hierarchy Standard) say that / tmp does not guarantee that files will remain after rebooting. In FHS, / var / tmp is a directory for temporary files that will not disappear even after a reboot.

Scroll to Top