Clean /tmp on Linux: remove old temporary files with tmpwatch
The /tmp partition on a Linux server is used to temporarily store files while various tasks are running. It is important to ensure that this partition does not become full, as it can affect system performance and cause unexpected issues.
In this tutorial, we will show you how to delete files older than 12 hours from the /tmp partition. By freeing up space in this partition, you ensure efficient server operation and help prevent potential errors or interruptions.
Follow the instructions below to clean the /tmp partition and keep your server in optimal condition. Remember to be cautious when deleting files and make sure you do not need any important data that may be stored in this partition.
Simply log in via SSH and run the following:
- tmpwatch -am 12 /tmp
This will remove all files older than 12 hours, meaning it will only keep files from the last 12 hours up to the time you run the command, and everything else will be discarded.
Caution: /tmp may contain temporary files that are currently in use. Run this cleanup preferably during periods of low activity.
Related Articles
How to delete iDrive e2 files using AWS CLI on Mac
When you need to delete large amounts of files from an iDrive e2 bucket, doing it through the web interface can take hours or even days. The most efficient solution is to use AWS CLI from your Mac terminal, as it processes multiple files in parallel ...
Adjust RAID Rebuild Speed in Linux
When a disk within a RAID array fails, manual rebuilding becomes a crucial process to restore the integrity and redundancy of the system. However, this task can be notoriously slow, resulting in prolonged periods of downtime and decreased system ...
Change Reserved Disk Space in Linux
The Linux operating system reserves a percentage of disk space when mounting a partition. This is done to allow the root user to log in even when the disk is full. This reservation, while useful, may seem like a waste of space, especially on ...
Using Screen on Linux: create, resume, and close terminal sessions
Screen is a command-line tool on Linux that allows you to manage multiple, persistent terminal sessions. With screen, you can run programs in the background, detach from a session without closing it, and resume it later. This is useful for ...
How to Block and Manage IPs in CSF via Command Line
CSF (ConfigServer Security & Firewall) is one of the most widely used firewalls on servers running cPanel/WHM. It allows advanced server access management, blocking or allowing IP addresses from the command line. In this article, you will learn how ...