The /tmp Lowdown
What is /tmp?
Think of your server's /tmp directory as a temporary digital workbench. It's a designated space where applications, system processes, and users can store short-lived files they need for a momentโlike caches, session files, or intermediate data during a process. It's designed for data that doesn't need to survive a system reboot.
The Perils of a Packed /tmp
When this workbench gets too cluttered, it can bring your server to a grinding halt. Here are the risks:
๐ฅ Application Crashes
Many programs depend on /tmp to function. If they can't write temporary files, they may fail to start or crash unexpectedly.
๐ซ Login Issues
Even logging into the server can become impossible, as creating new user sessions often requires writing to /tmp.
๐ System Instability
Critical system processes can be affected, leading to sluggish performance, strange errors, or even a complete system freeze.
The Cleanup Toolkit
Step 1: Identify the Culprits
Before deleting anything, you need to find out what's taking up all the space. These commands are your magnifying glass.
Check Overall Disk Usage
See a high-level overview of how full /tmp is.
Find the Biggest Offenders
List the top 20 largest files and directories inside /tmp.
Why Does /tmp Get Full?
Understanding the cause is key to prevention. Here are the usual suspects.
The Prevention Hub
Schedule Regular Reboots
The simplest solution. If your /tmp is a `tmpfs` (RAM disk), a reboot will wipe it clean. Ideal for non-critical servers.
Verify Automated Cleanup
Ensure `systemd-tmpfiles` or `tmpwatch` is enabled and configured correctly. It's the best long-term strategy.
Conduct Application Reviews
If one app is a repeat offender, check its configuration. It might be possible to change where it stores temporary files.