I'm considering making my application create a file in /tmp
. All I'm doing is making a temporary file that I'll copy to a new location. On a good day this looks like:
- Write the temp file
- Move the temp file to a new location
However on my system (RHEL 7) there is a file at /usr/lib/tmpfiles.d/tmp.conf
which indicates that /tmp
gets cleaned up every 10 days. From what I can tell this is the default installation. So, what I'm concerned about is that I have the following situation:
- Write the temp file
/tmp
gets cleaned up- Move the temp file to a new location (explodes)
Is my concern founded? If so, how is this problem solved in sophisticated programs? If there are no sophisticated tricks, then it's a bit puzzling to me as I don't have a concrete picture of what the utility of /tmp
is if it can be blown away completely at any moment.