This document provides the steps to clear a full partition. Usually, the /var directory fills up first, because it holds all of the system logs.
The /usr directory may also fill up quickly due to Apache.
To check the disk space from the command line, perform the following steps:
Log in to your server as the root user via SSH.
Examine your system to locate the directory or log that uses the most space. To do this, change to the /var directory and run the du -sh command.
The output will resemble the following example:
The numbers in the left column of the output represent the file size of each file and directory that the specified directory path contains, in human-readable format.
Due to the number of files and directories in the /var directory, this example only shows partial output from the du utility.
You can delete individual files within a directory and individual directories. To do this, perform the following steps:
Examine the size of each file in the directory. To do this, run the du -h * command. The output will resemble the following example:
du -h *
The following example displays the output for the /var/www/html directory.
To save the most recent entries, run the following commands:
In these commands, filename represents the file to delete, and filename.new represents the file to which to save the most recent entries.
tail -5000 filename > filename.new
mv filename.new filename
To delete the files, run the following command:
cat /dev/null > filename
After you delete the files and directories, restart the service that created the file. To do this, follow the directions in our How to Restart Services documentation.