
/tmp/ (/private/tmp/) : system-wide: cleared on reboot. and “un-accessed” files get deleted after 3 days by /etc/periodic/daily/110.clean-tmps (man periodic.conf) at 24-hour (86400 seconds) interval. the com.apple.periodic-daily.plist daemon.
/var/tmp/ (/private/var/tmp/) : system-wide: deleted on macOS update and/or upgrade. to be confirmed.
TMPDIR (/private/var/folders/…/T/) : per-user: “un-accessed” files get deleted after 3 days by the dirhelper daemon at 3:35am each day. the com.apple.bsd.dirhelper.plist daemon.
“un-accessed” files in the past 3 days in TMPDIR (/private/var/folders/…/T/) get cleared by the dirhelper daemon at 3:35am each day. and the TMPDIR directory path is coming from confstr() (POSIX string-valued configurable variables).
% grep -A6 StartCalendarInterval /System/Library/LaunchDaemons/com.apple.bsd.dirhelper.plist
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>35</integer>
</dict>
% getconf DARWIN_USER_TEMP_DIR
/var/folders/xx/xxxx_xxxx/T/
% getconf DARWIN_USER_CACHE_DIR
/var/folders/xx/xxxx_xxxx/C/
% man confstr
...
_CS_DARWIN_USER_TEMP_DIR
Provides the path to a user's temporary items directory. The directory will be created it if does
not already exist. This directory is created with access permissions of 0700 and restricted by the
umask(2) of the calling process and is a good location for temporary files.
By default, files in this location may be cleaned (removed) by the system if they are not accessed
in 3 days.
_CS_DARWIN_USER_CACHE_DIR
Provides the path to the user's cache directory. The directory will be created if it does not
already exist. This directory is created with access permissions of 0700 and restricted by the
umask(2) of the calling process and is a good location for user cache data as it will not be
automatically cleaned by the system.
Files in this location will be removed during safe boot.
...