So with Disk space being an issue I thought how can we clean up on a cPanel server. This script is not perfect but it does a good job of clearing about 1GB of disk space on average I have noticed.
So create a new bash script I like to use vim so I would do vim disk_cleanup.sh and paste the following in:
### Out Put for the boys and girls to See the before usage
#
df -h # ## Yum works best when cleaned often I have noticed
#
yum clean all # ## Remove all Compressed logs / remove any variations / incrementals
# rm -f /var/log/*.gz rm -f /var/log/*.? # ## And I said clean up after home! # # # Any Core files that may have been dumped as they take up a good 40 to 60Mb of Disk space.
rm -rf /home/core.* # Get rid of Easy Apache rm -rf /home/cpeasyapache # Get rid of Old MySQL Install rm -rf /home/MySQL-install # Get rid of other BS rm -f /home/latest rm -rf /home/cprubygemsbuild rm -rf /home/cprubybuild rm -rf /home/cprestore rm -rf /usr/local/cpanel/src/3rdparty/* cd /tmp for files in `ls`; do rm -f $files; done; # ## See what kind of Kernels you may have that are old but first lets remove any kernel sources
# rpm -qa kernel-source | xargs rpm -e # ## Display new space prior to any kernels being removed. #
df -h # ## List out the installed kernels # rpm -qa | grep kernel # ## Give current running kernel # uname -a | awk {’print $3′} # ## End #