Cleaning up /var

Cpanel and linux leaves a lot of log files in /var
After several years these can add up, especially in the cpanel/bandwidth folder. So a couple quick folder moves and symlinks can clean things up. This is assuming you have a /backup partition and some room in it.

Moving the log folder

mv /var/log /backup/
ln -s /backup/log /var/log

Moving the cpanel bandwidth folder

mv /var/cpanel/bandwidth /backup/
ln -s /backup/bandwidth /var/cpanel/bandwidth

Also just removing some of the log files in the log folder can help you for a quick fix.

Also use this command to find any other large folders:

du -ax –max-depth 1 /var | sort -n | tail

And in some cases you just need to clean your mail queue

/usr/sbin/exiqgrep -i | xargs /usr/sbin/exim -Mrm

Move your MySQL database folder as a last resort.

First always create a full mysqldump before ever doing something like this as well as stopping Service Manager > MySQL monitor option, since that will restart MySQL after you’ve stopped it and while you are moving it. The better steps are these:

1. Make a full mysqldump file:

mysqldump --all-databases | gzip > /home/alldatabases.sql.gz

2. Uncheck monitor in WHM > Service Manager for Mysql and save the area

3. Stop MySQL

/etc/init.d/mysql stop

4. Make the directory for MySQL in /home, move it and symlink it:

mkdir /home/var_mysql
mv /var/lib/mysql /home/var_mysql
chown -R mysql:mysql /home/var_mysql/mysql
ln -s /home/var_mysql/mysql /var/lib/mysql
/etc/init.d/mysql start

5. Re-check monitor in WHM > Service Manager for MySQL and save the area

Added for 2019 is the ability to move Softaculous:

Copy the folder /var/softaculous to /your/desired/path
Then update the path in the Softaculous Admin.