bsasninja

Well-Known Member
Sep 2, 2004
527
0
166
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?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
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?
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.
 

jols

Well-Known Member
Mar 13, 2004
1,107
3
168
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?
 

mtindor

Well-Known Member
Sep 14, 2004
1,392
71
178
inside a catfish
cPanel Access Level
Root Administrator
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?
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
 

jols

Well-Known Member
Mar 13, 2004
1,107
3
168
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?
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
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.
 

jols

Well-Known Member
Mar 13, 2004
1,107
3
168
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.
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
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.
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
 
Last edited: