WHM and logrotate - advice, please

magnusl

Registered
Oct 10, 2007
2
0
51
Running WHM 11.24.2 on RHEL.

I've only recently understood that there are some issues with log rotation on WHM/cPanel systems, and that it might take some customization to make rotation work in a nice way. Which is kind of strange since just about everything else about WHM/cPanel seems to be designed to be handled by anyone who can handle a keyboard and a mouse.

Yes, I know there are settings in WHM ("Apache Configuration" and "cPanel Log Rotation Configuration") that makes WHM handle rotation for files in
/usr/local/apache/logs
/usr/local/cpanel/logs​
But Apache files seem to be rotated only above 300MB?
Well, I like my files smaller than that and therefore want to use a custom log rotation.

Additionally, it seems some files are not covered by the above settings - these were mentioned somewhere:
/var/log/xferlog
/var/log/chkservd.log​

And what about files in /usr/local/cpanel/logs/cpbackup, do they stick around for ever?

I've added the below lines to my /etc/logrotate.conf, and would love some input from a WHM guru on their sanity and completeness.

I've used the "service" binary rather than "kill -HUP", doing a hard restart of pure-ftpd but restarting apache gracefully. Is this the way to do it?

/var/log/xferlog {
weekly
rotate 1
postrotate
/sbin/service pure-ftpd restart > /dev/null 2>/dev/null || true​
endscript
}

/var/log/chkservd.log {
weekly
rotate 1
}

/usr/local/cpanel/logs/cpbackup/*.log {
weekly
rotate 1
}

/usr/local/cpanel/logs/*log {
weekly
rotate 1
}

/usr/local/apache/logs/*log {
daily
rotate 7
sharedscripts
postrotate
/sbin/service httpd graceful > /dev/null 2>/dev/null || true​
endscript
}
 
Last edited:

nichiyume

Member
Nov 18, 2004
18
0
151
Phoenix, Az
You could just edit /etc/logrotate.d/httpd and change the directory here:

Code:
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
Or if you already have files there, you can create another file in logroate.d with the other directory you are interested in. Just because logrotate rotates the cpanel logs doesn't mean that the new logs will be written. The daemon could be trying to write to a non-existant file and so they would have to be restarted. Using Main >> Service Configuration >> cPanel Log Rotation Configuration is best for those logs in case the Cpanel daemons need to be restarted.