What is private/var/tmp ?

Discussion in 'Apple' started by john_doe_ph_d, Nov 29, 2005.

  1. I recently ran a backup/cloning program (SuperDuper) on several
    machines. On two of the machines, the size of the clone matched closely
    the total size of the files on the source. However, on the third
    machine, the clone was about 3 GB less than the source. In the log of
    the clone, there are many contiguous items showing omitted files from
    private/var/tmp. I assume from the folder name that these are temporary
    files of some sort.

    What gets put into private/var/tmp and is it safe to empty it out? If
    so, how do you go about doing that since I don't think I was able to
    get to it with the Finder.

    Thanks.
     
    john_doe_ph_d, Nov 29, 2005
    #1
    1. Advertisements

  2. On 29/11/2005 11:23 AM, wrote:
    [...]
    Safe to ignore, as this is just a place for tempfiles used by system
    daemons and the like. One can get to /var/tmp via the Terminal. I
    think the Finder hides anything that resolves to /private.

    It is /probably/ safe to empty this out, though there could be stuff in
    there currently in use. If you really have 3Gb in there, then something
    is not being cleaned up. On many BSD systems, both /tmp and /var/tmp
    are cleaned up on boot. Maybe one of the periodic scripts or a startup
    script does this on OS X? I've never needed to look for this, and my
    Tiger box is not to hand right now.
     
    void * clvrmnky(), Nov 29, 2005
    #2
    1. Advertisements

  3. john_doe_ph_d

    Hauke Fath Guest

    Care to name a few that clear out /var/tmp?

    I'd _hate_ that...

    hauke
     
    Hauke Fath, Nov 29, 2005
    #3
  4. I'd have to look, but I think OpenBSD pokes around in /var/tmp for files
    it knows it created.
     
    void * clvrmnky(), Nov 29, 2005
    #4
  5. I already did this. I realize these are temporary files, so I am not
    questioning their omission from the clone by SuperDuper!. I am asking
    OS X questions: where do these files come from (since there's about 3
    GB of them) and how can I get rid of them if that is advisable?
     
    john_doe_ph_d, Nov 29, 2005
    #5
  6. Or more easily by using the Finder menu command "Go To Folder".

    Paolo
     
    Paolo Cordone, Nov 29, 2005
    #6
  7. john_doe_ph_d

    justin Guest

    These are created by applications which are processing the files you
    are working on. If you are burning a DVD an "image" will be created in
    a format this particular app outputs to, for instance.

    System dumps quite a lot of stuff in here too.

    Usually these files are deleted on application quit or on restart.

    It is safe to empty the _content_ of the temp folder, but the process
    is automatic. Just hard restart your machine - it is a Good thing.

    j.
     
    justin, Nov 29, 2005
    #7
  8. john_doe_ph_d

    D P Schreber Guest

    This is the standard place for applications to store temporary files.
    Lots of apps leave things there. To get rid of them, ensure that the
    standard periodic maintenance scripts are running. If you leave your
    Mac on over night, you're fine. If you don't, install anacron.
    Assuming the maintenace scripts are running, no file will stay in tmp
    for more than 3 days.
     
    D P Schreber, Nov 30, 2005
    #8
  9. john_doe_ph_d

    justin Guest


    Cron won't clean all temp files and, speaking of periodic -daily,
    -weekly, -monthly, it may not work:

    " If your Mac is neither shutdown nor in sleep mode at the scripts'
    scheduled times, the launchd process will only execute the scripts on
    schedule one time. Unless you restart your Mac daily Ñ in addition to
    assuring it is neither shutdown nor in sleep mode at the scheduled
    times Ñ you should run the maintenance scripts manually. "

    http://www.thexlab.com/faqs/maintscripts.html
     
    justin, Nov 30, 2005
    #9
  10. john_doe_ph_d

    D P Schreber Guest

    I wasn't talking about cron.


    Thus my reference to anacron.
     
    D P Schreber, Dec 1, 2005
    #10
  11. john_doe_ph_d

    justin Guest

    Which is a third party scheduler running identical scripts as unix cron
    executable.

    Cron, Anacron, whatever, they all schedule the execution of an unix
    command "periodic" (daily, weekly, monthly).

    "periodic" won't clean all these files.

    Drop a file in /temp, run CLI "periodic daily", see what happens.

    j.
     
    justin, Dec 1, 2005
    #11
  12. john_doe_ph_d

    D P Schreber Guest

    Take another look at the daily scripts.

    I described this already. One of the daily scripts removes files in
    /tmp that are more than 3 days old.

    Should I describe it again?
     
    D P Schreber, Dec 2, 2005
    #12
  13. john_doe_ph_d

    justin Guest

    No, it will remove files not _accesesed_ in past 3 days. Hair-splitting
    as this may be, it will still leave OP with the junk he was complaining
    about.

    In other words once written, but read ocassionaly, a file will be left
    intact until you restart the machine, until i-nodes get rebuilt.
    Please? Here is the script:



    1: #!/bin/sh -
    2: #
    3: # @(#)daily 8.2 (Berkeley) 1/25/94
    4: #
    5: PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
    6: host=`hostname -s`
    7: bak=/var/backups
    8:
    9: echo ""
    10: echo "Removing scratch and junk files:"
    11:
    12: if [ -d /var/rwho ] ; then
    13: cd /var/rwho && {
    14: find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
    15: fi
    16:
    17: # Clean up junk files.
    18: #find / \( ! -fstype local -o -fstype rdonly \) -a -prune
    19: -o \
    20: # \( -name '[#,]*' -o -name '.#*' -o -name a.out -o
    21: -name '*.core' \
    22: # -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
    23: # -a -atime +3 -exec rm -f -- {} \;
    24:
    25: # Clean up NFS turds. May be useful on NFS servers.
    26: #if [ "${host}" != "localhost" ]; then
    27: # find / -name .nfs\* -mtime +7 -exec rm -f -- {} \; -o
    28: -fstype nfs -prune
    29: #fi
    30:
    31: if [ -d /tmp ]; then
    32: cd /tmp && {
    33: find . -fstype local -type f -atime +3 -ctime +3 -exec
    34: rm -f -- {} \;
    35: find -d . -fstype local ! -name . -type d -mtime +1
    36: -exec rmdir -- {} \; \
    37: >/dev/null 2>&1; }
    38: fi
    39:
    40: # remove system messages older than 21 days
    41: msgs -c
    42:
    43: if [ -f /var/account/acct ] ; then
    44: if [ -x /usr/bin/gzip ]; then gzext=".gz"; else
    45: gzext=""; fi
    46: echo ""
    47: echo "Gathering accounting statistics:"
    48: cd /var/account
    49: if [ -f "acct.2${gzext}" ] ; then mv -f
    50: "acct.2${gzext}" "acct.3${gzext}" ; fi
    51: if [ -f "acct.1${gzext}" ] ; then mv -f
    52: "acct.1${gzext}" "acct.2${gzext}" ; fi
    53: if [ -f "acct.0${gzext}" ] ; then mv -f
    54: "acct.0${gzext}" "acct.1${gzext}" ; fi
    55: cp -pf acct acct.0
    56: if [ -x /usr/bin/gzip ]; then gzip -9 acct.0; fi
    57: sa -s > /dev/null
    58: fi
    59:
    60: if [ -d /var/db/netinfo ]; then
    61: echo ""
    62: echo "Backing up NetInfo data"
    63: cd /var/db/netinfo
    64: for domain in *.nidb; do
    65: domain=$(basename $domain .nidb)
    66: server=`nicl -t localhost/$domain -statistics | grep tag |
    67: awk '{print $3}'`
    68: if [ $server = master ] ; then nidump -r / -t
    69: localhost/$domain > $bak/$domain.nidump; fi
    70: done
    71: fi
    72:
    73: echo ""
    74: echo "Checking subsystem status:"
    75:
    76: echo ""
    77: echo "disks:"
    78: df -k -l
    79: echo ""
    80: dump W
    81:
    82: if [ -d /var/spool/mqueue ]; then
    83: echo ""
    84: echo "mail:"
    85: mailq
    86: fi
    87:
    88: echo ""
    89: echo "network:"
    90: netstat -i
    91:
    92: echo ""
    93: if [ -d /var/rwho ] ; then
    94: ruptime
    95: fi
    96:
    97: echo ""
    98: echo -n "Rotating log files:"
    99: cd /var/log
    100: for i in system.log; do
    101: if [ -f "${i}" ]; then
    102: echo -n " ${i}"
    103: if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext="";
    104: fi
    105: if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}"
    106: "${i}.7${gzext}"; fi
    107: if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}"
    108: "${i}.6${gzext}"; fi
    109: if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}"
    110: "${i}.5${gzext}"; fi
    111: if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}"
    112: "${i}.4${gzext}"; fi
    113: if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}"
    114: "${i}.3${gzext}"; fi
    115: if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}"
    116: "${i}.2${gzext}"; fi
    117: if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}"
    118: "${i}.1${gzext}"; fi
    119: if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x
    120: /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
    121: touch "${i}" && chmod 640 "${i}" && chown root:admin "${i}"
    122: fi
    123: done
    124: if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat
    125: /var/run/syslog.pid | head -1); fi
    126: echo ""
    127:
    128: if [ -d /var/log/httpd ]; then
    129: echo ""
    130: echo -n "Cleaning web server log files:"
    131: cd /var/log/httpd && \
    132: find . -type f -name '*_log*' -mtime +7 -exec rm -f -- {}
    133: \; >/dev/null 2>&1;
    134: fi
    135:
    136: if [ -f /etc/daily.local ]; then
    137: echo ""
    138: echo "Running daily.local:"
    139: sh /etc/daily.local
    140: fi
    141:
    142: if [ -f /etc/security ]; then
    143: echo ""
    144: echo "Running security:"
    145: sh /etc/security 2>&1 | sendmail root
    146: fi
     
    justin, Dec 2, 2005
    #13
  14. john_doe_ph_d

    David C. Guest

    I don't know of any that do this by default, but I know of many
    installations where the sysadmins configure this. It's also common to
    have cron jobs that walk through /tmp and /var/tmp and delete anything
    with the last-access date older than than 30 days ago.

    These kinds of policies were very common on university systems when I
    was in college.

    As for hating this behavior, why? You shouldn't be using the tmp file
    systems for storing anything of value. They're only supposed to be used
    for temporary files, which should be meaningless once the associated app
    quits.

    -- David
     
    David C., Dec 5, 2005
    #14
  15. john_doe_ph_d

    David C. Guest

    If some program is accessing the files on a regular basis, do you really
    want to purge them?
    As it should be. If they're being used by some application, then you
    don't want them being summarily deleted.

    -- David
     
    David C., Dec 5, 2005
    #15
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.