Categories

cPanel log file woes

cPanel log rotator fills up the server HDD with useless junk files

cPanel log rotator fills up the server HDD with useless junk files


One of cPanel-based servers (cPanel/WHM 11.30.5.2) I administer has thrown a tantrum tonight. A cPanel log rotator has stuck (in fact, multiple instances were running at the same time) and the end result was very not pretty. The server was extremely sluggish and half of the services were restarting several times an hour.
Upon investigation, it turned out that the Apache log directory
/usr/local/apache/domlogs is filled up with useless junk files like the ones on the picture above. The files are in this naming format:

ftpxferlog.offsetftpsep.1.gz.1.gz.2.gz.2.gz.3.gz.1.gz.1.gz.1.gz.1.gz.1.gz.4.gz
example.com-bytes_log.1.gz.1.gz.2.gz.2.gz.3.gz.1.gz.1.gz.1.gz.1.gz.1.gz.4.gz

and the amount of them was so great that running rm resulted in error:

rm -rf bytes-log*
/bin/rm: Argument list too long.

which is a result of linux kernel not being able to fit all the file names rm needs to delete into the 128Kb exec() environment buffer.

Well, there is a workaround for that – use output of the find command to feed rm the file names as arguments:

find . -name '*bytes_log*' | xargs rm
find . -name 'ftpxferlog*' | xargs rm

*bytes_log* should take care of all domains hosted on this server.

It would not hurt to run cPanel upgrade script /scripts/upcp after cleaning the server to see if there is a new stable version out there.

Happy server cleaning!