Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Ubutu 10.04. I have some apps that create a few temporary files in /tmp/<file> as part of their shutdown process. I want to inspect those files when the apps are closed in the event of a system shutdown. However, when the system comes up again I find that all temporary files have been deleted. How can I ask the system not to clear the files in /tmp/ on shutdown?

share|improve this question

migrated from Jun 2 '10 at 16:33

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

You can define when files from /tmp can be deleted. You should change the value of TMPTIME variable form /etc/default/rcS file.

The default value of these variable is 0 - these means that files will be deleted every time computer starts. Set up TMPTIME to 3 means that will delete files older than 3 days.

But you can set TMPTIME=infinite - these means that the files will be never deleted.

share|improve this answer
Since my requirement is to inspect the files for debugging purposes, this solution works best for me. – 341008 Oct 23 '14 at 16:29

/tmp is often an in memory file system so once you reboot, it's gone.

Instead of trying to preserve /tmp, I would try to get my processes to write to a different directory. If they are written well, the apps should honor the TMPDIR environment variable to decide where to write temp files; you can then have it point to another directory such as /var/tmp which should survive a reboot.

share|improve this answer

you could change the times that files in /tmp have to be modified in order to delete them. but if you configure your linux distro to keep the files /tmp for ever and/or a long time then you hard disk will be filled with useless (or not) files in /tmp directory .. take a look here

share|improve this answer
Taking into account the comment about /tmp being mounted as a "ramdisk" (aka tmpfs), use the mount command to make sure your system wasn't configured that way. – pcapademic Jun 2 '10 at 18:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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