11 Ways to Free Up Disk Space on a cPanel Server
- Written by Vanessa Vasile
- Published in Fixes, Howto, Linux
- 53 Comments
- Permalink
I’m sure that most of you have been to the point where one or more of your servers start to fill up as you get more customers. The server’s performing just fine, but there’s one problem…you’re out of disk space! Here are a few simple tricks to freeing up disk space on your cPanel server to help maximize your server’s potential.
1) Delete user cPanel and Fantastsico 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
To remove Fantastico backups:
rm -rfv /home/*/fantastico_backups
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:
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
7) 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
8) Decrease the reserved disk space
By default, Linux reserves 5% of the disk space from each partition for the root user, so root can still log in even if the disk is full. You may have noticed when running a df that you may be using 900GB out of a 1TB drive, but only have 50GB available…that’s because the other 50GB is reserved.
For larger drives, you really don’t need the whole 5%. I would recommend setting this value down to 2500 blocks so you can utilize more of the disk space. You can do this with tune2fs:
tune2fs -r 2500 /dev/sda1
You’ll want to probably man the tune2fs command before you use it for other options on setting the reserved space for your partitions.
9) Remove unneeded accounts
If you have a larger churn rate you probably 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> <y/n> (y/n indicating whether to save the DNS records)
10) Check for contrabands
As a hosting provider you should have a Terms of Service that specifically tells your customers what they can (or rather cannot) store on your server. Most hosts have specific rules about the hosting of non-website-related backups and copyrighted material, but don’t pro actively scan their servers for it. It wouldn’t hurt to run a few locate commands to find common files associated with copyright violations, like .mp3, .avi, .exe, etc, and have your customers remove them from the server. I once cleared over 300Gb of space on a server just by having customers remove contraband files from the server. On top of that, you’re also preserving the integrity of your business from a legal standpoint.
11) 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. A lot of hosting providers have alternate servers that are more “low key” but have huge disk storage volumes to accommodate customers that have larger sites. You might want to consider investing in a server that will be less populated and only the users that occupy a large amount of space.
53 Comments
Pingback: Drive Warning: /dev/sda3 (/usr) is 86% full - please help - cPanel Forums
Thanks mate , i own a blog and have 1000 mb so if i ever need some space , i will try to delete some unnecesary files .
Great post, well done. Just used it to fix up my VPS which was 99% full. Recovered 600mb of free space immediately using your tips.
Aaron
This post is the only guide I found
Thanks alot
Pingback: 5 Easy Tips to Free Up Disk Space on Your Server | eLief Blog
Where should I go to to execute these commands?
You’d execute them from command line – if you need help, please check out our consultation services.
How about a non-command version… jezz
Well, if you’re attempting to administer a server and can’t even copy the commands listed in the post, maybe you shouldn’t be doing this anyways 🙂
Thanks it did work nicely, and helped me a lot , my whole server was filled and it was bit too much tricky to reduce the space and we cannot delete few stuffs from cpanel if we do not have some disk space
Joe if you can’t run commands on your server then you should hire a professional admin todo it for you…. jezz
Pingback: Removing WHM Disk Space Errors | IT Admins
Pingback: Removing WHM Disk Space Errors | TurboNoc.com
Pingback: Fixing Quotas on a cPanel Server | TurboNoc.com
rm -fv /home/*/tmp/Cpanel_*
rm-fv? What is this. How to find it? I don’t understand.
Thanks!
You run this from command line. If you’re not familiar with the unix shell, I would recommend not performing these actions as a root user 🙂
Pingback: Removing WHM Disk Space Errors :: The cPanel Admin
Good guide. But don’t you think it’d be too harsh to bluntly delete all the fantastico / softaculous backups without the permission of the users? They might have something important in there.
Also, is there any better way to archive the emails to save some space in case the user is consuming like 10GB just for mails?
This guide is only intended for informational purposes. Whether a system administrator would choose to do this depends on the policies of their company. Many hosts have a ToS clause stating that backups generated by cPanel (including Fantastico/Softaculous) are fair game if they are left on the server too long. Additionally, users should be responsible for maintaining their own offsite website backups.
Nice post really appreciated. It will definitely help me to reduce disk space and loading time
Very nice tips. I found out my server was filled up. Looked in the Fantastico file and saw that the file size it has backed up is really huge. That was when i decided to see what others say about deleting these file. I was worried it would have a negative impact. I have saved the file to my computer already. So, i guess i’ll have to delete it and make some space.
Thank You for providing good information…thanks ….
Pingback: Pablo Valenzuela » Blog Archive » Liberar espacio en Cpanel
thanks, really helpful post. I was running out of disk space and was not able to upload any media file (pictures) on my wordpress blog. By following these tips, i was able to recover about 400 MB of disk space.
However one should check the hosting plan, if you have bought unlimited hosting plan, you can always ask for more disk space to your hosting provider.
Brilliant! Thankyou. I just freed up 11GB of space using your tips. Can’t thank you enough.
I don’t know to execute these commands?
Via SSH.
How clear mail disk-space of an account?
Great help, thank you!
This post is “timeless”! Found several of these tips to be helpful today..several years later. It pops up near the top of Google results which is a good thing!
Thanks
is there any way to find it via cpanel or WHM interface?
As mentioned, you have to do this via SSH as a root user.
I want to know that , If file server shows too many temporary files then how we can fix it.
I’m a beginner , so need your help.
Hi Vanessa, i need your help, please suggest something.
Thanks in advance.
Clarify what you mean by “temporary files”. What are you seeing and where are you seeing them?
Very nice and detailed info. User backups and reserved space, two things I have kept in mind from this post to keep my server somewhat more relaxed. Thanks a lot.
dear vanessa
thank you for usefull post,i just go and want to do command with ssh but there is not option called “connect using java” in my panel ,how can i enable it?
SSH into the server from an SSH client.
Hello,
Thanks. It’s Very Helpful.
🙂
Thank you for the useful post.
This bash script might be helpful to combine said above and run all the operations to free up the disk space:
# Delete error_log files larger then 10MB
find /home/*/public_html/ -type f -name “error_log” -size +10M -delete
# Delete Backups stored in /home/user/ folder
for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done
# Delete cPanel File Manager temp files
rm -fv /home/*/tmp/Cpanel_*
# Remove pure-ftp partials
locate .pureftpd-upload | xargs rm -fv
Save these commands into the file under /root/DiskCleanupScripts.sh
and add cron job in /var/spool/cron/root file:
40 4 */2 * * /root/DiskCleanupScripts.sh
So this will run every 2-nd day at 4:40am.
this locate .pureftpd-upload | xargs rm -fv does not seems to be working in my case.
What is the output of the command? Please also make sure you are running as root.
what is the optimum CPU usage in Cpanel?
how cpu resources are measured?
Very nice topic. After applying to delete tmp folder and empty trash I have made 12GB space. Thanks thecpaneladmin.
Thank You for your great post .
Pingback: How to clear disk space on cPanel server ⋆ SysAdminStuff
Pingback: phpini در سی پنل کجاست
I want to contribute with this… It has helped me to save tons of space with unwanted mails.. It will delete spam, trash and junk mails that were received 24hrs or later.
find -P /home/*/mail/*/*/.Junk/* -mindepth 1 -maxdepth 1 -mtime ‘+1’ -delete
find -P /home/*/mail/*/*/.Spam/* -mindepth 1 -maxdepth 1 -mtime ‘+1’ -delete
find -P /home/*/mail/*/*/.Trash/* -mindepth 1 -maxdepth 1 -mtime ‘+1’ -delete
Carefull.. if you need to keep trash mails dont run the last command.
I have a Question, Can u Help me!
I am using Freehosting with 10GB storage space, suddenly I got an error when I was trying to upload an image. When I checked hosting File manager, my public_html directory is full of the only 240mb memory usage.
What should I do now? Please help me… I am new to WordPress and Hosting kinds of stuff.
Thank you!
Pingback: Top Performing Cpanel Hosting Reddit | Web Hosting
Pingback: Top Performing Whm Reddit | Web Hosting
when hard reach to 99% , Cpanel stop working on this partition , is it possible do any action to prevent this ?
well explained, and helped me tons , my whole server was filled and it had been bit an excessive amount of tricky to scale back the space and that we cannot delete few stuffs from cpanel if we don’t have some disc space
WHERE do you input the commands???? Thanks.