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.

Script to reset Apache logs at the end of the month

Discussion in 'EasyApache' started by Jeff75, Jun 8, 2004.

  1. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    Does anybody know of a script that can be ran at the end of the month to reset all log files in the /usr/local/apache/domlogs directory via crontab? I am sick to death of cPanel and it's goofy log resetting. It resets log files 1, 2, 3, 4 days before the end of the month at all different times and screws up my customized Urchin stats. My clients are always bitching about their stats being missing the one or two days at the end of the month. I've paid over $1000 to be able to use Urchin and because cPanel refuses to make the log rotation configurable, the stats are not even accurate. This isn't that big a deal for Bob who wants to see how many hits his blog had last month, but for most of my clients' sites (business sites), it's important to them to see accurate stats.

    If someone knows of a script that I can run via crontab at the end of each month to reset my clients' log files can you please link me to it or post it in the forums? I'd like to disable to Apache log rotation in WHM and set the script to delete the logs after my Urchin stats to run. I can also modify the time that AwStats and Webalizer run so they will be updated as well before the rotation.
     
  2. netlook

    netlook Well-Known Member
    PartnerNOC

    Joined:
    Mar 25, 2004
    Messages:
    335
    Likes Received:
    0
    Trophy Points:
    16
  3. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    Not sure if this will work, I just tested it on one domain and it worked fine.

    I decided I wanted to keep the last 100 lines so mine does just that.

    Code:
    cd /usr/local/apache/domlogs
    tail -f domain.com > domain
    cat domain > domain.com
    rm domain
    
    Now if you want to null out the file:
    Code:
    cd /usr/local/apache/domlogs
    > domain.com
    
    Where domain.com is the domain's log file.

    If you want to do them all:

    Code:
    cd /usr/local/apache/domlogs
    for i in `ls *.com`
    do
       > $i.com
    done
    
    This will null out every .com file in the directory.
     
  4. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    Albert,

    Do you know how to turn that into a script that can be ran via crontab and will also work for any domain tld?
     
Loading...

Share This Page