How to Optimize Disk Space on cPanel / WHM Server

Run these commands to clean up old logs, old backups, spam in mail queue, etc.

Mail Queue

exim -bp | grep \< | awk '{print $3}' | xargs exim -Mrm

/Home Log Files

find /home -type f -name error_log -delete

Old User Backups

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

Unnecessary System Files

updatedb
locate .pureftpd-upload | xargs rm -fv 
locate -r /core\.[0-9] | grep /home | egrep -v 'virtfs|php|sql|ini'

Old Log Files

rm -rf /usr/local/apache.backup*
rm -fv /home/*/tmp/Cpanel_* 
rm -rvf /home*/cpanelpkgrestore.TMP*
rm -fv /home*/*/.softaculous/backups/*
rm -rvf /home/cpmove-*
rm -f /var/log/*.gz 
rm -f /var/log/exim_mainlog-*
rm -f /var/log/exim_paniclog-*
rm -f /var/log/exim_rejectlog-*
rm -f /var/log/lve-stats.log-*
rm -f /var/log/apache2/archive/*
rm /home/*.tar.gz -fv
rm /home/*/public_html/error_log -fv
rm /home/*/public_html/*/error_log -fv
rm /home/*/public_html/*/*/error_log -fv
rm /home/*/public_html/*/*/*/error_log -fv
rm /home/*/public_html/*/*/*/*/error_log -fv 
cd /var/log
rm -f cagefs.log-* cron-* maillog-* messages-* secure-* spooler-* up2date-* *.gz
yum clean all

Optimize MySQL Databases

mysqlcheck --auto-repair --optimize --all-databases

 

March 14, 2019   48    CPanel / WHM    
Total 1 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?


Leave a Comment