Overview
This document explains several methods to help you manage your server's hard drive space.
Important:
We strongly recommend that you keep at least 10% of your server's available disk space free.
Examine disk space usage
To determine how much available space exists on your server's file systems, run the following command:
Note:
The
df
command returns a table that displays basic information about each mounted file system.- The
-h
argument returns the results in a human-readable format.
The output will resemble the following example:
This output displays that the system's main storage device (
/dev/mapper/LogVol00
) which is mounted in the root
(/) directory uses 70% of its available disk space, and contains 85 gigabytes (GB) of free space.Examine disk space usage by file and directory
To determine which files and directories consume most of your hard drive space, run the following command:
Notes:
- This command displays the estimated disk space of each file and directory that your root directory (
/)
contains, in human-readable format.- The
-s
argument returns a summary of your present working directory's contents, but does not return each file and directory's disk usage information individually. - The
-h
argument returns the command's results in human-readable format. - The slash (
/
) argument returns the contents of theroot
(/
) directory.
- The
- We recommend that you only run this command in off-peak hours to prevent additional load on your server.
The output will resemble the following example:
The numbers in the left column represent the sizes of the files and directories that the working directory contains, in human-readable format.
In the example above, the
/home
directory uses the most disk space, with 113 gigabytes (GB). However, that directory likely contains your cPanel accounts. Since you will most likely not remove your users' data, examine the /var
directory for disk usage data. To do this, run the following command:
Note:
In the example above, the asterisk (
*
) wildcard argument that lists the summarized, human-readable disk usage information for every file and directory in the /var
directory.
The output will resemble the following example:
The output displays that the
/var/logs/
directory uses the most disk space.
Repeat this process to locate more files to remove.
Remove unnecessary files
To clear some disk space, run the
rm
utility to remove some files from the file system, for example:
Warning:
Exercise caution when you run the
rm
utility. You cannot recover files or directories that you delete.
In the example above,
filename
represents the path to the file or directory to remove. The -f
argument forces the file's removal, and the system does notprompt you to confirm that you wish to remove the file. This argument saves time if you use an asterisk (*
) as a wildcard to remove multiple files.
For example, to remove an old audit log file, change to the
/var/log/audit
directory and perform the following steps:- Locate the
audit.log
file that occupies the most disk space. To do this, run the following command:
The output will resemble the following example: - Run the following command to remove the
audit.log
file that occupies the most disk space:This command will not return output. - Confirm that the
audit.log.3
file no longer exists. To do this, run the following command:The output will resemble the following example:
Repeat this process until you clear enough disk space.
How to Clean Log Files Before You Enable Log Rotation
How to Clean Log Files Before You Enable Log Rotation
0 comments:
Post a Comment