Logs, temp & system internals

How to Clear /tmp and /private/tmp on Mac Without Breaking Anything (2026)

If you have ever tried to clear tmp on Mac and wondered whether it is actually safe, you are not alone. The /tmp directory — which is really just a symlink to /private/tmp on macOS — accumulates scratch files from apps, installers, Xcode builds, and system services. On a busy developer machine it can balloon to several gigabytes. This guide explains exactly what lives there, what you can safely remove, and how to do it without destabilising your system on macOS Sequoia or Tahoe, whether you are on Apple Silicon or Intel.

What Is /tmp on Mac and Where Does It Actually Live?

macOS follows POSIX convention and exposes /tmp at the root of the filesystem. In practice, /tmp is a symbolic link that points to /private/tmp, which is the real directory. You can confirm this yourself:

ls -la /tmp

You should see output like /tmp -> private/tmp. Both paths reach the same files. The directory is world-writable with the sticky bit set, meaning any user or process can create files there, but only the owner of a file (or root) can delete it.

macOS does not guarantee an automatic cleanup schedule the way Linux's systemd-tmpfiles does. Instead, the OS clears /private/tmp on every reboot — but reboots on Apple Silicon Macs are infrequent, so files can accumulate for weeks or months between restarts.

What Kinds of Files Accumulate in /private/tmp?

The contents vary by how you use your Mac. Common categories include:

  • Installer staging files — package installers (.pkg) expand payloads here before copying them to their final destinations.
  • Xcode build intermediates — some older build scripts and code-signing steps write temporary outputs to /tmp. (Most Xcode intermediate products land in ~/Library/Developer/Xcode/DerivedData instead.)
  • Shell script scratch files — any script that calls mktemp creates a uniquely-named file or directory here.
  • App crash data and lock files — some third-party apps write lock files (.lock, .pid) or temporary logs to /private/tmp.
  • Compiler and linker temps — Clang, Rust (via ~/.cargo for cache, but /tmp for in-process intermediates), and Java tools (separate from ~/.m2/repository) all use it during compilation.
  • Homebrew install tarballs — Homebrew extracts source archives to a subdirectory under /tmp before building bottles.

How Much Space Can /private/tmp Use? A Sizing Reference

User profile Typical /private/tmp size Main contributors
Casual user (light app use, infrequent reboots) 50 MB – 300 MB App update staging, occasional installer leftovers
Developer (Xcode + Homebrew, compiles weekly) 500 MB – 3 GB Homebrew build tarballs, Clang/linker temps, code-signing intermediates
Heavy CI / build automation (long uptime) 3 GB – 10 GB+ Parallel build jobs, test runner scratch, Docker layer staging

If your Mac has been running for months without a reboot, auditing /private/tmp is one of the first things worth doing when you are trying to free up space on Mac.

Is It Safe to Delete Files in /private/tmp?

In general, yes — with one important caveat. Files in /private/tmp that belong to a currently running process should not be deleted while that process is active. Deleting a lock file mid-run can confuse the application that owns it. Deleting an in-progress installer's staging directory can corrupt the install.

The safest approach is:

  1. Quit all open applications and stop any running builds or package installs.
  2. Check whether any processes have files open in /private/tmp before deleting anything.
  3. Delete only files you are confident are orphaned (i.e., no running process owns them).

Rebooting is the zero-risk option — macOS clears the directory automatically on boot. If you want to clear it without rebooting, the manual steps below are the next best thing.

How to Clear /private/tmp on Mac Manually (Step-by-Step)

Step 1: Check what is actually there

Open Terminal and list the contents with sizes:

sudo du -sh /private/tmp/* 2>/dev/null | sort -rh | head -30

This shows the largest items first. Note any directories with recognisable names from apps you use actively — do not remove those yet.

Step 2: Identify open file handles in /private/tmp

Run this to see which processes currently have files open there:

sudo lsof +D /private/tmp 2>/dev/null

If the output is empty (or shows only your Terminal session), it is safe to proceed with cleanup. If you see other processes, quit them first or wait until they finish.

Step 3: Remove orphaned files and directories

Delete everything older than 24 hours that no running process has open:

sudo find /private/tmp -mindepth 1 -mtime +1 -exec rm -rf {} + 2>/dev/null

The -mindepth 1 flag prevents the command from attempting to remove /private/tmp itself. The -mtime +1 filter skips files modified within the last day, which reduces the chance of touching something in active use.

Step 4: Verify the result

du -sh /private/tmp

You should see a much smaller number. On a developer machine that hasn't been rebooted in months, this single step can reclaim several gigabytes.

What to Leave Alone in /private/tmp

Some files in /private/tmp look orphaned but are actually important for a running session:

  • SSH agent socketsssh-XXXXXX/agent.NNN directories are created by ssh-agent and your shell relies on them during the current login session.
  • Launchd socket files — certain daemons register UNIX domain sockets under /private/tmp. Deleting them forces the service to restart (usually harmless but occasionally disruptive).
  • Running installer payloads — if a .pkg is installing right now, its staging directory must not be touched.

When in doubt, reboot — it is the cleanest and safest option.

/tmp vs. Other Temp Locations on Mac: Know What You Are Cleaning

macOS spreads temporary and cached data across several locations. Clearing only /private/tmp often misses the larger space hogs. Here is a quick map:

  • /private/tmp — system-wide temp files, cleared on reboot.
  • ~/Library/Caches — per-user app caches; safe to clear on a per-app basis. See our guide on how to clear system cache on Mac for details.
  • ~/Library/Developer/Xcode/DerivedData — Xcode build products; can grow to 20–50 GB on active projects.
  • ~/.cargo/registry — Rust crate source cache (not a temp dir, but often forgotten).
  • ~/.m2/repository — Maven artifact cache for Java projects.
  • /var/folders — per-user temporary files managed by launchd; macOS auto-expires entries here, so manual cleanup is rarely needed.

If you want a single view of all these locations, a tool like Crumb can audit all of them at once and show what is safe before you delete anything — particularly useful when you are trying to understand what is actually eating your disk.

Automating /private/tmp Cleanup Without Surprises

Rather than running manual commands each month, you can create a launchd agent that removes old files on a schedule. Save the following plist to ~/Library/LaunchAgents/com.user.tmpcleaner.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.user.tmpcleaner</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/find</string>
    <string>/private/tmp</string>
    <string>-mindepth</string>
    <string>1</string>
    <string>-mtime</string>
    <string>+7</string>
    <string>-exec</string>
    <string>rm</string>
    <string>-rf</string>
    <string>{}</string>
    <string>+</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>3</integer>
    <key>Minute</key>
    <integer>0</integer>
  </dict>
</dict>
</plist>

Load it with:

launchctl load ~/Library/LaunchAgents/com.user.tmpcleaner.plist

This runs every night at 3 AM and removes any file or directory in /private/tmp not modified in the past seven days. The seven-day window gives long-running installs or background jobs time to finish before their scratch files are swept away.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Is it safe to delete everything in /private/tmp on Mac?
It is safe to delete files that no running process currently has open. The safest method is to reboot, which clears the directory automatically. If you cannot reboot, use lsof to check for active file handles before deleting anything, and avoid removing SSH agent sockets or in-progress installer payloads.
Where is /tmp on a Mac — is it different from /private/tmp?
/tmp is a symbolic link that points to /private/tmp, so they are the same directory. Any file you see via one path is identically accessible via the other. You can confirm this by running 'ls -la /tmp' in Terminal, which will show the symlink target.
Will deleting /private/tmp files lose any important data?
No. The /private/tmp directory is intentionally ephemeral — it holds scratch files that apps and installers create as working space, not permanent documents or settings. macOS itself clears the directory on every reboot, so nothing important should ever be stored there long-term.
How much space can clearing /private/tmp recover?
For casual users, usually 50–300 MB. On a developer machine with months of Homebrew builds, Xcode code-signing intermediates, and compiler temps, it can be 1–5 GB or more. Run 'sudo du -sh /private/tmp' to see your current total before cleaning.
Does macOS Sequoia or Tahoe automatically clean /private/tmp?
macOS clears /private/tmp on reboot but does not run a background periodic cleanup the way some Linux distributions do. On Apple Silicon Macs with long uptimes, the directory can accumulate weeks of temp files. A manual cleanup or a scheduled launchd agent is the most reliable way to keep it under control.