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/

  • 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

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).

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .