Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

What is the differences between these directories?
How long is the files stored in each of them?

The oldest file/folder I could find in each of them were

  • /prviate/tmp, 13 days old
  • /private/var/tmp, 28 days old (2-3 days after I upgraded to Lion)
  • TMPDIR, 1 day old

Note: TMPDIR is what you get when running echo $TMPDIR in Terminal. My TMPDIR is /var/folders/3y/d44gn_2x7vv8d9d67969f54c0000gn/T/

share|improve this question
    
Good question. I just checked and I think /private/var/tmp sticks around longer because I have stuff in there from over a year ago. –  styfle Aug 21 '11 at 3:16

1 Answer 1

up vote 9 down vote accepted

TMPDIR as defined in OSX is only accessible by yourself which reduces the risk of somebody else accessing your temp files created by programs using mktemp() to create temporary files.

The difference between /tmp and /var/tmp is more subtle and goes back a long way in the Unix world, the discussion concerning the differences and uses are probably going on since the first Unix system was deployed with both (see Google for long list of links). /tmp resides on the root filesystem so it it accessible as soon as the system starts (even if no other disk is mounted yet) but may be rather small. The /var filesystem usually is in another partition and much bigger. I've also encountered systems where /tmp was just a ramdisk or a symlink to /var/tmp. It's not that way on OSX though.

/tmp is cleared out regularly on OSX (see /etc/defaults/periodic.conf), /var/tmp very rarely (if at all).

share|improve this answer

Your Answer

 
discard

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.