Create More Free Space On Your Server
If you notice you are not able to connect to your cPanel, Webmail, or WHM and your website is slow and giving errors, your server may be maxed out on the disk space.
How to view your overall disk size and usage
1. Log into your server via SSH
If you are using the Macintosh OS X Terminal or Linux command prompt use the following:
ssh root@ipaddress
Replace ipaddress with your server’s physical IP address
If you are using MS Windows then you can use a terminal application such as Putty.
Once you have logged in use the df command to review your disk usage.
df -h
You will get a similar to the following output.
root@vps#### [~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/server 154G 153G 1.0G 99% / tmpfs 2.1G 0 2.1G 0% /dev/shm /dev/sdb1 159G 14G 137G 9% /backup /dev/sda1 508M 135M 347M 28% /boot /dev/sda3 2.2G 124M 1.9G 7% /tmp
This Output shows that out of the 154 gigs of total disk space, 153 gigs are used with 1GB of space left over. This leaves the server at 99% disk space. This is enough to cause cPanel login failures, FTP file upload errors, and slow website issues. At this point you will need to remove some of the files from the server to bring the server back to normal operation.
How to find files with a certain size
There are two commands you can use to check which folder files are taking up your disk space. You can use the “find” or the “du” command. Below explains the two commands you can use.
Finding all file sizes with the “du” command
The following command will display all files and folders sorted by MegaBytes.
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'
You will get a similar to the following output.
0 MB ./.htpasswds 0 MB ./.trash 0 MB ./public_ftp 0 MB ./etc 0 MB ./.fontconfig 0 MB ./.cpanel 0 MB ./mail 4 MB ./tmp 1173 MB ./public_html 1224 MB .
This output shows that all files over 1 MB are in the /public_html. You can run this command on a directory basis to find folders that are large. Also, this command can be customized to refine your search.
Finding specific file sizes using the “find” command
Below is the “find”command that looks for specific files in the “home” directory. The following script is finding files that are 500000k or larger
find /home -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
The previous command will output a similar result like the following.
/home/userna5/public_html/error_log: 514M /home/userna5/backup-userna5.tar.gz: 738M
Here you can see that there is a backup that is 738MB large. You can find your backup files that are no longer needed and remove them to free up space.
In the example above to remove the error_log file from the userna5 account you would enter:
cd /home/userna5/public_html/ rm error_log
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:
for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done
Move your backups to a VMware SAN Disk
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 one of our VMware SAN Disk storage services to your hosting server and store the backups there. AUSWEB offers a range of external backup plans that provide that extra level of security with a variety of storage capacities.
To learn more about VMware San Storage options and how to order them please visit:
Externally mounted Backup Disk Space for Linux and Windows VMware Servers
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:
rm -fv /home/*/tmp/Cpanel_*
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.
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
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:
locate .pureftpd-upload | xargs rm -fv
*If you don’t run an updatedb regularly, you might want to do so before running this command
Remove unneeded accounts
It may turn out that you have some user accounts laying around on your server that you don’t need. Check out WHM > List Suspended Accounts (or ls /var/cpanel/suspended) and look for suspended accounts that you may be able to remove from the server to free up space. You can terminate accounts in WHM > Terminate an Account or using the command:
/scripts/killacct user
Consider a larger server
Some of your customers may have a legitimate need for large amount of disk space, and therefore you may be unable to keep the disk space usage on your server at a reasonable level.
We would first recommend using our VMware SAN Disk storage solutions to move your backups off your server. This should help to free a considerable amount of disk space, whilst allowing important backups to continue being generated.
If however you have reached a point where you have outgrown your current hard disk storage then you may need to look at migrating your platform to a new server. Just contact our support staff to discuss what options are available to allow you to upgrade to a new server platform.