Overview

This document outlines the steps to clear a full partition. Typically, the /var directory is the first to become full, as it stores all system logs.

Note: The /usr directory can also rapidly consume space due to Apache.

Clear a Full Partition

Check Directory Space from the Command Line

To ascertain disk space from the command line, follow these steps:

  1. Log in to your server as the root user via SSH.
  2. Examine your system to identify the directory or log file that consumes the most space. To do this, navigate to the /var directory and execute the du -sh command.
    • The du utility reports the estimated disk space usage for each file and directory within the specified path.
    • The -sh argument formats the output in a human-readable size.
  3. The output will appear similar to the following example:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
          4.0K    ./cpanel/acllists
          0   ./cpanel/analytics/data
          0   ./cpanel/analytics/logs
          0   ./cpanel/analytics/run
          4.0K    ./cpanel/analytics
          24K ./cpanel/plugins/wordpress-instance-manager-plugin
          24K ./cpanel/plugins
          0   ./cpanel/passreset
          8.0K    ./cpanel/mailman/diskusage_cache
          8.0K    ./cpanel/mailman
          563M    ./cpanel
          4.0K    ./named/data
          0   ./named/dynamic
          0   ./named/slaves
          124K    ./named/cache
          236K    ./named
          44K ./www/html
          0   ./www/cgi-bin
          44K ./www
          0   ./cvs
          0   ./proftpd
          2.8G    .
        

    The numbers in the left column of the output indicate the file size of each file and directory within the specified directory path, presented in a human-readable format.

    Note: Due to the large number of files and directories in the /var directory, this example displays only partial output from the du utility.

  4. Review the output to pinpoint which directories consume the most space.

Delete Selected Files and Directories

You have the option to delete individual files and directories. To proceed, follow these steps:

  1. Navigate to the directories that consume the most disk space.
  2. Examine the size of each file within the directory. Execute the du -h * command to do this.
  3. The output will appear similar to the following example:

    Note: The following example illustrates the output for the /var/www/html directory.

    1
    2
    3
    4
    5
    6
    7
    8
    4.0K    400.shtml
    4.0K    401.shtml
    4.0K    403.shtml
    4.0K    404.shtml
    4.0K    413.shtml
    4.0K    500.shtml
    12K cp_errordocument.shtml
    4.0K    index.html
  4. Either delete the files or preserve the most recent entries.
    • To save the most recent entries, execute the following commands:

      Note: In these commands, filename denotes the file to be deleted, and filename.new represents the file where the most recent entries will be saved.

      tail -5000 filename > filename.new
      mv filename.new filename
      sync
    • To delete the files, execute the following command:
      rm filename

Restart the Service

Once files and directories have been deleted, restart the service responsible for creating them. Refer to our How to Restart Services documentation for instructions.


Related Resources

War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)