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.

6GB error_log file not rotating!!!

Discussion in 'General Discussion' started by bsasninja, Jun 4, 2009.

  1. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    I´m having a problem with apache error_log file at /usr/local/apache/logs/
    I have deleted and created the file on monday and today is 6.3gb again, seems that is not rotating the logs daily.
    I´ve 404.shtml files in all the accounts

    -rw-r--r-- 1 root root 6.3G Jun 4 14:02 error_log

    any help?
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    In WHM -> Service Configuration -> Apache Configuration -> Log Rotation try checking the box for "error_log" then clicking save. Note, you may want to also log rotate the rest of the logs on that page.

    Unlike user's HTTP logs, these logs will be rotated once they reach 300 MB in size.
     
  3. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    cPanelDavidG, what about the error_log files that are located within the individual hosted accounts? I just found one error_log file in someone's account that was over 600,000 lines deep! Anything we can do to keep these from eating up web space, that is, without switching this feature off entirely in php.ini?
     
  4. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,279
    Likes Received:
    36
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    If your customer has error_log files that are huge in their own directories, let them reach quota and ask you why their account doesn't work - then you can tell them have have obvious broken PHP scripts generating copious amounts of errors.

    This si really your customer's problem and not yours directly - and you should contact your customer and tell them to either fix whatever is broken and generating the huge files or tell them to go elsewhere.... or just delete the error logs yourself once in a while.

    Mike
     
  5. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    But I am sure, as you probably know there are scripting errors which have no real impact on their scripts or anything else.

    True, such errors are due to poor coding, etc. but in our view, the last thing we need are accounts failing due to "unknown" reasons. (from the customer's point of view)

    And, ANYTHING to reduce support calls is a plus.

    So I take it then, that it is up to us to come up with a script that regularly looks at the size of the error_log files and rotates them when they get too large?
     
  6. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    We have a cronjob that sweeps error_logs from all user accounts regularly
    and checks the size before deletion and the number of times it has to sweep
    that particular user and above a certain threshold, it sends us an email to
    go check out the user's account.

    Regarding Mr. 6 GB though, it would seem you have a major problem because
    there is no way the default log for the server should be growing that fast
    unless there is something going on that there shouldn't be.
     
  7. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Spiral, sounds like just what the doctor ordered.

    Care to post the script that's run by your cron? Last time I tried to set up a shell script to do something like this it caused CPU overloads. I'm really not very good at this kind of thing.
     
  8. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    The following is not what we use ...

    However, someone in another thread asked almost an identical question about error_logs literally
    just a couple of minutes ago and I wrote them a quick script to locate and archive the error_log files so
    here is a variation of the script I just posted in the other thread just a minute ago except rewritten
    to be more used as a cronjob and may be useful to what you are doing as well and should be easily
    modified to add whatever additional functionality you need:
    Code:
    #!/bin/bash
    IFS="$"
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    PATH=$PATH:$HOME/bin:/usr/mbin:.
    
    export PATH
    unset USERNAME
    
    TLOG="/tmp/tmp_error_search.$$"
    ELOG="/var/log/client_error_logs.log
    
    # Reset temporary work file if exists
    if [ -e ${TLOG} ]; then
       rm -f ${TLOG}
       /bin/touch ${TLOG}
       /bin/chmod 600 ${TLOG}
    fi
    
    cd /home   #Nice starting point
    
    ls /var/cpanel/users | while read CPLN; do
        echo "$(date) I will now search ${CPLN}'s account for PHP error_log files ..." >> ${ELOG}
        find /home/${CPLN}/public_html -type f -name 'error_log' > ${TLOG}
    done
    
    if [ -e ${TLOG} ]; then
      echo "$(date) I have built my list of error_log files and am now archiving those files ..."  >> ${ELOG}
      cat ${TLOG} | while read MLINE; do
         if [ -e ${MLINE}.bz2 ]; then
            rm -f ${MLINE}.bz2 
            echo "$(date) Removed old archive ${MLINE}.bz2 from hard drive ..."  >> ${ELOG}
         fi
         echo "$(date) Compressing ${MLINE} into new bzip2 archive ..." >> ${ELOG}
         bzip2 -9 "${MLINE}" > /dev/null 2>&1
      done
      rm -f ${TLOG}
    fi
    
     
    #8 Spiral, Jul 11, 2009
    Last edited: Jul 11, 2009
  9. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Cool. Thanks very much.
     
Loading...

Share This Page