Single Blog

Safely empty MySQL .log & .err files on cPanel Servers

January 3, 2017, Written by 0 comment

Over time the .log & .err files on cPanel servers can become huge, more often that not you should always investigate what is causing these files to generate to huge capacity in case there are issues with the databases that you are running.

We always investigate and keep our servers tidy, so ensuring these are regularly cleaned help us to monitor and fix any problems with MySQL.

cat /dev/null is often referred to a black hole in Linux based systems because it discards all data written and sends End of File character to any process reading data from it. This lets us clear the contents of a file.

Navigate to the MySQL directory on cPanel

cd /var/lib/mysql/

Run ls -l to find your file

ls -l

Clear the contents of the MySQL Error Log and Log File

cat /dev/null > /var/lib/mysql/mysql.server.com.err

cat /dev/null > /var/lib/mysql/mysql.server.com.log

Check the files are empty

ls -l mysql.server.com.err

ls -l mysql.server.com.log

James Ensor