1. Delete user cPanel backups
If you have the backup feature in cPanel enabled, chances are your users are storing the backups on the server instead of downloading and removing them. On larger servers, this can account for a lot of disk space usage. You may want to consider warning your users ahead of time that backups will automatically be removed from the server after a certain period of time or on certain dates. 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
Similarly to above, if you’re using the cPanel Backup System and are storing your backups locally on the server, you could be using twice as much space as you need to. 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 File Manager within cPanel, File Manager 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 rather 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 server.
5. Remove cPanel update archives
Cpanel and EasyApache updates tend to leave behind files that you probably don’t need. The following can be deleted or moved to a backup server to free up a little bit of space:
/usr/local/apache .backup* |
/home/cpeasyapache (actual name may vary depending on cpanel version)
6. 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 |