How to determine high disk usage locations

This article describes how to determine where your account is using the most disk space.

Determining disk usage

To maintain the reliability and performance of servers for all users, A2 Hosting monitors disk space usage. If you have a lot of files and directories, though, you may not know where exactly your account is using the most disk space.

To determine your account's disk usage, follow these steps:

  1. Log in to your account using SSH.
  2. To make sure you are in your home directory, type the following command:
    cd ~
  3. Type the following command:

    du -sh * | sort -h
    If you have a large number of files and directories in your account, this command may take some time to complete.

    This one-line command uses the du command to calculate disk usage statistics for every file and directory in the current directory (in this case, your home directory). It then uses the sort command to sort the data usage statistics, with the smallest files and directories at the top, and the largest files and directories at the bottom. The following example shows typical output from the command:

    0       access-logs
    0       www
    4.0K    a2backups
    4.0K    bin
    4.0K    perl5
    8.0K    public_ftp
    132K    etc
    448K    php
    3.3M    tmp
    20M     mail
    87M     public_html
    
  4. To view disk usage for a particular subdirectory, change to the directory (for example, type cd public_html), and then rerun the command in step 3. You can progressively step into subdirectories, run the command, and determine where exactly your account is using the most disk space.

    You can add the total amount of disk space usage to the output by using the -c option for the du command. For example:

    du -shc * | sort -h

Reducing disk usage

If disk space usage for your account is too high, you should try to determine the cause as soon as possible so you can bring it back down to an acceptable level. Some common causes of high disk usage are:

  • Databases: Comment spam from unsecured WordPress applications can cause a database to grow very quickly.  Similarly, an account receiving large amounts of spam can cause log files to grow large. Consider adding CAPTCHA protection to your web site. For more information about how to reduce spam, please see these articles.
  • Recursive backups: Consider this scenario—you create a backup. Then a WordPress plugin or cron job creates a backup of the backup. Before you know it, you have a runaway process creating files of increasing size. This is a guaranteed way to quickly use up disk space. Make sure you are aware of all the processes on your account that may create a backup or other large file, and make sure they do not conflict with each other.
  • Cron jobs or other automated processes: Automated processes, such as cron jobs, can create a large number of files very quickly. Either modify or disable the cron job, or delete the unwanted files.
  • E-mail messages: Old messages in the Trash and Sent folders of users' mailboxes often accumulate. You can download these messages to your local computer (if you want to save them), and then delete them on the server.
If your web site's storage needs are increasing, please contact our sales department at http://my.a2hosting.com to discuss upgrade options. Common upgrades for shared hosting accounts are a managed VPS or a dedicated server. These packages offer dedicated resources that can streamline your site's performance. They also include full management and the cPanel control panel.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.