Optimize Your Server Disk Space

The following steps will help you optimize your server disk space on Cloudways.

Cloudways Product avatar
Written by Cloudways Product
Updated over a week ago

Table of Contents

Your server disk space has a critical role in keeping your website’s availability higher and supporting all storage-related operations. Over time, your server and applications data take up more space, which gradually approaches 100% disk capacity.

Running out of storage is an unfortunate event and can render your server unavailable, crash your website, worst of all, destroy your visitor’s experience. Scaling up your disk space is a solution, but a smarter approach would be to normalize disk usage through the Cloudways Disk Cleanup utility, which helps clean up unnecessary files, logs, and local backups to save plenty of disk space.

Tip

You can easily check your server disk usage from the server monitoring section of the Cloudways Platform.

How to Optimize Your Server Disk Space

The following steps will help you optimize your server disk space. Please note that if you have multiple servers in your account, running optimization on one server will not affect the other servers.

Optimize Server Disk — Navigate to Settings & Packages

Log in to your Cloudways Platform using your email address and password.

  1. From the top menu bar, open Servers.

  2. Then, select your desired server.

    Classic Interface

    New Interface

  3. Under Server Management, select Settings & Packages.

  4. Now, switch to the Optimization tab.

    Classic Interface

    New Interface

Optimize Server Disk — On-demand Disk Cleanup Optimization

The on-demand disk cleanup has various customizations that can be selected to clean up multiple files and folders at once. If none of the custom cleanup options are selected, ‘Run Cleanup’ will only execute the default operation listed first, e.g., “Remove temporary files not needed by your applications” which cannot be unchecked and will run each time disk cleanup is executed.

Default Actions —The default selection “Remove temporary files not needed by your applications” limits itself to clean a few default files and folders, which are considered non-vital and can be safely removed at any point in time. Cloudways Disk Cleanup utility takes the following measures by default:ult:

  • Remove unessential files ending with .log and .gz extension from the tmp directory.

/tmp/*.log

/tmp/*.gz

  • Remove ImageMagick files from the tmp directory.

/tmp/magick-*

  • Remove unnecessary system files from the var directory.

/var/lib/apt/lists/*

/var/cache/apt/archives/*

/var/tmp/*

To run the disk cleanup using default configurations, leave all the choices blank and click Run Cleanup.

Classic Interface

New Interface

By selecting any of the 5 custom choices, you can increase the disk optimization functionality to yield more free disk space.

  1. “Remove all files from the ‘tmp’ folder for all Applications” — If selected this option will remove all temp files and folders located inside the tmp directory of all your applications ( /home/master/applications/<application_name>/tmp).

  2. “Remove all files from the ‘private_html’ folder for all Applications” — This choice gives you the ability to delete all files and folders inside the private_html directory of all your applications (/home/master/applications/<application_name>/private_html).

Tip

Both custom cleanup options 1 & 2 are handy if your application does accumulate some kind of daily files that would need to be cleared over a period of time.

3. “Remove all files from the ‘local_backups’ folder for all Applications” — If you keep local backups of your applications on your server, these might be taking disk space. We recommend that you always offload your local backups or download them to your personal computer after creation. Selecting this option will delete the local backup of all your applications (/home/master/applications/<application_name>/local_backups).

If this option is executed during a scheduled or manual local backup process, then the disk cleanup tool will delete such temporary backup files to free up disk space. It is always recommended that this option is selected when no local backup operations are running.

4. “Remove archived files from ‘logs’ folder for all Applications” — Your application logs are critical for debugging and troubleshooting the application-level issues; however, the older logs are not helpful, so there is no point keeping them on the server. Log files are written daily, and the older logs are compressed and archived. Selecting this option takes the following measures:

  • Remove all the compressed old logs ending with .gz extension from all your applications’ logs folder (/home/master/applications/<application_name>/logs).

  • Archive the current log file, and start writing a new log file. The process will only keep logs for the last few hours.

5. “Remove archived files from ‘/var/log’ folder” — Your system log files are written daily and the older logs are compressed and archived. Just like application logs, old system logs are not beneficial and can be removed from your server. Selecting this option takes the following measures:

  • Removes PHP, Database, and Mail compressed log files from the var directory

/var/log/php*.log.*

/var/log/mysql.*

/var/log/mysql/*.log*

/var/log/mail*.log.*

  • Remove files from the journal directory.

/var/log/journal/*

  • Archive the current log files, and start writing new logs. The process will only keep logs for the last few hours.

Tip

Options 3 to 5 are the most common options customers look for when optimizing their disk space.

Once you have selected the required cleanup methods, you can click Run Cleanup.

Classic Interface

New Interface

Optimize Server Disk — Automatic Disk Cleanup Optimization

The automatic disk cleanup optimization is enabled by default which means that the Cloudways Platform will automatically trigger the optimization whenever the server’s main disk (root partition) reaches 80% disk usage or over. If other logical partitions such as block storage reach usage 80% or higher, the automatic disk cleanup will not intervene.

You can enhance the automatic disk cleanup functionality by using the custom cleanup options as shown in the following steps:

  1. Customize the optimization using the custom cleanup options available.

  2. Make sure that the automatic disk cleanup is On.

  3. Finally, click Save Changes.

Classic Interface

New Interface

If the disk cleanup process is unable to take your disk usage requirements down to a level below 80%, the process will attempt further cleanups at an interval of 4 hours. At this point, we do recommend scaling up your disk space to avoid running out of space on your main disk. CloudwaysBot will also alert you about low disk space once you hit 95% usage of total available capacity.

Important

Automatic Disk Cleanup Optimization will always run with your previously saved preferences. Running on-demand optimization with different preferences will not affect automatic optimization.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?