The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WHM and logrotate - advice, please

Discussion in 'General Discussion' started by magnusl, Mar 25, 2009.

  1. magnusl

    magnusl Registered

    Joined:
    Oct 10, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    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
    }
     
    #1 magnusl, Mar 25, 2009
    Last edited: Mar 25, 2009
  2. nichiyume

    nichiyume Member

    Joined:
    Nov 18, 2004
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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.
     
Loading...

Share This Page