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.

Add file to log rotate

Discussion in 'General Discussion' started by verdon, Nov 29, 2005.

  1. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Hi,

    I have a manual install of mod_security which is working well. It logs to /usr/local/apache/logs/audit_log. I want to add this file to the auto log rotate. I added a file /etc/logrotate.d/mod_security with the following...

    /usr/local/apache/logs/audit_log {
    missingok
    postrotate
    endscript
    }

    Is there something else I need to do? It didn't seem to work, or at least there was no /usr/local/apache/logs/audit_log.1 this morning.

    Thanks,
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Try adding the line daily to get it to do it daily. Perhaps better is to do it with the apache logs otherwise it won't rotate properly as apache needs to ne restarted to use the new log. So, change /etc/logrotate.d/httpd to look like this instead:

    Code:
    /etc/httpd/logs/*log {
        missingok
        notifempty
        sharedscripts
        compress
        postrotate
            /bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
        endscript
    }
    
    That will now catch all the logs including audit_log. That will rotate them weekly by default, as before add daily within that on its own line to do it daily. To force a rotation to check it out run:

    /usr/sbin/logrotate -vf /etc/logrotate.conf
     
  3. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Thanks chirpy... great advice as always :)

    I see the weekly directive now in /etc/logrotate.conf (DOH!) Am I understanding correctly that this can be over-ridden in the individual directives included in /etc/logrotate.d ?

    BTW... curiously enough, I don't have a /etc/logrotate.d/httpd though. Never looked before to be honest. From the size and age of access_log and error_log, maybe I should ;)

    Very best regards,
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Those logs and the ones in /usr/local/cpanel/logs/ are two directories of the few that cPanel doesn't configure logrotated to rotate (the other main ones are the domain SSL logs in /var/log/).
     
  5. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    I wonder why?

    Anywise, your instruction above worked well. Logrotate is a nice utility!
     
  6. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    18
    But if you rotate your domlogs, you can mess up your stats. Any way around that? I even tried the awstats value to archive and make a backup of the archived files - but Cpanel seems to not allow awstats to do so..

    PurgeLogFile=1
    ArchiveLogRecords=1

    were the valuse in awstats.conf.
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    I don't rotate my domlogs, I leave that to cPanel. If they're too big, I'd suggest either rotating them after each stats run (WHM setting) or simply moving the domlogs directory to a bigger partition and symlinking it.
     
  8. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    18
    Partition is no the problem. When domlogs gets to 2 gigs, Apache quits adding to them and therefore all stats are lost.
     
  9. abubin

    abubin Well-Known Member

    Joined:
    Dec 7, 2004
    Messages:
    393
    Likes Received:
    1
    Trophy Points:
    18
    ah...domlogs. One of the things I hate about cpanel is how badly it handle domlogs. It doesn't give you options to back it up or anything and when you try to take control of it, your stats will go haywire.

    So, my method of doing logs is to leave domlogs alone. I create my own domain logs (access_log) in httpd.conf. Yes, this uses a little more resources but it doesn't screw up anything. Any updates I apply to cpanel will continue to work without problems. I would suggest you look into doing your own access_log if you don't mind the tiny extra loads.

    If you really need to tweak it, you can add logs only to domains that is very busy. For domains that doesn't have much traffic. You won't have the 2GB problem therefore allowing you to rotate those domlogs directly.
     
  10. forlinuxsupport

    forlinuxsupport Well-Known Member
    PartnerNOC

    Joined:
    Dec 22, 2004
    Messages:
    386
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    bugizlla enhancement

    hey guys

    Please look here is a bugzilla enhancement I opened with cpanel.
    http://bugzilla.cpanel.net/show_bug.cgi?id=3153

    Please vote for it so we can get this fixed, it really becomes a nasty issue near the end of the month when the logs grow to over 2 gig.

    It would be nice if we could specify the rotation date/time. E.g. rotate the domlogs at the end of each week. And also keep a copy in the users home directory etc.

    Please add comments to the bugzilla entry.

    Im using TRUSTIX and have the 2 gig file issue, what OSes are you guys using ?

    Cheers
    Andy
     
  11. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    18
    abubin - could some sample on how you did that? Would make a lot of our lives easier....

    Thanks.
     
  12. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    18
    Or anyone else?
     
  13. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16


    Isn't there something to be added to crontab -e or just create that file and add the code, restart apache?
     
  14. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You don't have to add anything else or do anything else. Logrotate will pick it up the next time it runs from the logrotate job that you should have in /etc/cron.daily/
     
Loading...

Share This Page