I notice that even when my Mac machine is not restarted. Files in /tmp more than a few days will disappear. Does macOS periodically purge files in /tmp?
My macOS is 11.4.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityI notice that even when my Mac machine is not restarted. Files in /tmp more than a few days will disappear. Does macOS periodically purge files in /tmp?
My macOS is 11.4.
The answer here suggests that the periodic daily script indeed deletes older files in /tmp.
It is triggered by /System/Library/LaunchDaemons/com.apple.periodic-daily.plist
which seems to run /usr/sbin/periodic
daily (via a wrapper).
From the configuration file (/etc/defaults/periodic.conf
):
# 110.clean-tmps
daily_clean_tmps_enable="YES" # Delete stuff daily
daily_clean_tmps_dirs="/tmp" # Delete under here
daily_clean_tmps_days="3" # If not accessed for
daily_clean_tmps_ignore=".X*-lock .X11-unix .ICE-unix .font-unix .XIM-unix"
daily_clean_tmps_ignore="$daily_clean_tmps_ignore quota.user quota.group"
# Don't delete these
So anything which hasn't been accessed in the last three days will be deleted (unless it matches a name in daily_clean_tmps_ignore
).
There is this Apple document, which states the following:
/tmp
This directory is used for general shared temporary storage. It is cleared out each time the system starts up.
/var/tmp
This directory is used for general shared temporary storage. Although you should not count on data stored in this directory being permanent, unlike /tmp
, the /var/tmp
directory is currently not cleared out on reboot.
Note: The document is Copyright © 2016 by Apple Inc, which makes the information about 6 years old at the time this answer was posted.
/tmp
and /var/tmp
is not specific to Apple's Unix. See Other References in my updated answer.
Mar 28 at 8:58