fbpx

How to clean up cPanel disk space

Having a full disk can interfere with the speed and efficiency of our server. You may experience downtime, slow website loading, emails not arriving to your mailbox. The tips below will help you free disk space and maximize your account’s potential.

1.  Delete user cPanel backups

cPanel has a backup feature available. If enabled, a copy of your cPanel control panel settings and other data will be stored in the backup folder. On larger servers, this folder could take up a lot of disk space. In that case, the best way to free up the disk space in cPanel is by deleting some data from the backup folder. You can either delete the data one-by-one or mass-delete the entire user cPanel.

You can mass-delete all user cPanel backups on the server with this command via SSH:

for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done

2.  Move your backups offsite

On the other hand, you should consider mounting a backup server to your hosting server and storing the backups there (there is an option to mount external media in WHM > Configure Backups) or using an alternate method of backing up your server that doesn’t involve storing the backups locally. While local backups may be convenient at times, they tend to be useless when a server failure occurs.

3. Delete cPanel File Manager temp files

When users upload files in the File Manager within cPanel, it creates a temp file that may or may not get removed upon upload. You can remove these files using this command via SSH:

rm -fv /home/*/tmp/Cpanel_*

4. Move or archive logs

Most of the server’s logs are stored in /var/log, which can get large on more populated servers. You can change the length of time and frequency of the log rotation in /etc/logrotate.conf, and enable compression to save additional space (at the expense of CPU when the logs are being gzipped). If you want older logs, consider creating a cron job to periodically transfer them to a backup or log server so they aren’t taking up space on your hosting account.

5. Clean up Yum files

Yum updates leave package cache files on the server. You can clean up all unneeded yum files by running:

yum clean all

6. Remove pure-ftp partials

When your users upload files to the server via FTP when your server runs pureFTP as an FTP daemon, the FTP server creates temporary files starting with .pureftpd-upload* that get renamed the the actual filename when the upload completes. If the upload doesn’t complete, these files are left on the server. You can find and delete these by running this command via SSH:

locate .pureftpd-upload | xargs rm -fv

7. Consider upgrading the disk server on your account

You may have a legitimate need for a large amount of disk space, and therefore you may be unable to keep the disk space usage on your account at a reasonable level. A lot of hosting providers have alternate servers that don’t have as much in the way of resources but have huge disk storage volumes to accommodate customers that have larger sites. You might want to consider investing in a higher disk capacity.

Updated on September 30, 2021

Was this article helpful?

Related Articles

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.