Web Hosting Talk







View Full Version : Cpanel Apache Log File Rotation


koZZmo
07-20-2001, 06:52 PM
The logs for each domain are being created in the /usr/local/apache/domlogs directory. Yet they grow and grow. Does anyone have a solution that will trim the logs and keep them in a manageable size? Maybe being able to say "Keep last 90 days" or something like that. It's just that eventually these files will get too big and take up too much space.

Thanks!

Tim Greer
07-20-2001, 07:15 PM
If you're running Cpanel, you're running Linux. Every Linux system I've seen, has logrotate. Check you're /etc directory. Check the file logrotate.conf and type in "man logrotate", and it'll pull up the manual about it and tell you how to use it. You can have logs trimed, deleted or backed up (and compressed) (and then even deleted after they are so old), and how many rotations it will have.

I wouldn't suggest waiting 90 days for a log to rotate, if that's what you meant, but you can surely have it rotate each month for 3 rotations (90 days), but I'd have it rotate around the time the logs are processed, for 4 rotations. You can and should do the same for any logs, like the /var/log/messages, etc. I'd suggest compressing them on each rotation, and after the 4th or 5th rotation, to back them up somewhere, just for the sake of log reviewing and whatnot.

Brian Farkas
07-20-2001, 07:16 PM
If you have some accounts that have particularly big log files, you could try adding them to the /etc/logrotate.d/apache file with something like this:

/usr/local/apache/domlogs/domain.com {
rotate 3
monthly
compress
}

I believe this should work... It would rotate the log file monthly, and keep backups for the last 3 months. I'm not sure whether you can replace domain.com with * to do this for all logs in that directory, but I know that does work for specific domains.

Good luck, I hope this helps.

Brian Farkas

teck
07-23-2001, 01:40 PM
Originally posted by Tim_Greer

I wouldn't suggest waiting 90 days for a log to rotate, if that's what you meant, but you can surely have it rotate each month for 3 rotations (90 days), but I'd have it rotate around the time the logs are processed, for 4 rotations. You can and should do the same for any logs, like the /var/log/messages, etc. I'd suggest compressing them on each rotation, and after the 4th or 5th rotation, to back them up somewhere, just for the sake of log reviewing and whatnot.

Tim,

What do you mean by having them rotate around the time they are processed? What would be optimal? What logrotate flags would be the best to use?

gordita
08-09-2001, 04:00 PM
I'm also using Cpanel and can't find how the apache logs are rotate.

They seem to be cleared on a 4 week schedule, but I can't tell that they are being rotated by logrotate. No mention of them is found in /etc/logrotate.conf and only the following files are in /etc/logrotate.d/:
/etc/logrotate.d/exim
/etc/logrotate.d/named
/etc/logrotate.d/linuxconf
/etc/logrotate.d/mars-nwe.log
/etc/logrotate.d/samba
/etc/logrotate.d/syslog
/etc/logrotate.d/uucp
/etc/logrotate.d/cron
/etc/logrotate.d/mysql

My guess at this point is that Cpanel uses it's own internal log rotation mechanism :-(

Does anybody know more about this?

Brad
08-09-2001, 11:20 PM
We have Cpanel and this is what it shows in our logrotate.conf


# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# send errors to root
errors root

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

# system-specific logs may be configured here



Originally posted by gordita
I'm also using Cpanel and can't find how the apache logs are rotate.

They seem to be cleared on a 4 week schedule, but I can't tell that they are being rotated by logrotate. No mention of them is found in /etc/logrotate.conf and only the following files are in /etc/logrotate.d/:
/etc/logrotate.d/exim
/etc/logrotate.d/named
/etc/logrotate.d/linuxconf
/etc/logrotate.d/mars-nwe.log
/etc/logrotate.d/samba
/etc/logrotate.d/syslog
/etc/logrotate.d/uucp
/etc/logrotate.d/cron
/etc/logrotate.d/mysql

My guess at this point is that Cpanel uses it's own internal log rotation mechanism :-(

Does anybody know more about this?

gordita
08-10-2001, 10:13 AM
Yes, my /etc/logrotate.conf is identical to Brad's. But that doesn't include any directives for /usr/local/apache/domlogs/*... does it? I was expecting there to be a directive similar to:
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

or find something in the included /etc/logrotate.d directory. But as you can see from my previous post it's not in that directory either.

Brad: It seems that default logrotate directives specified in our /etc/logrotate.conf files are what is being used for apache logs, however where does it mention the apache logs? I'd like to change the directives, but change them only specificaly for the apache logs and not the default directives thus changing who knows what else.

regier
08-10-2001, 10:03 PM
Bascially the logs are processed daily on all accounts. All that I do when the /usr directory gets full is go into the domlogs directory and do a
rm -f *
then
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/https start

This will clear them all down to zero again. Sure you loose a couple of hours of log data, but it isn't all that big of a deal. Everything will continue counting from where it was at already. Therefore all totals are acurate except for the couple hours that are missing.

eva2000
08-11-2001, 12:08 AM
my domlogs directory always gets filled up at least twice a month and my /usr partition is 4GB!

what i do is

cd /usr/local/apache/domlogs

mv the 4 files partaining to the domain with the largest log files normally between 500 - 900MB to directory on /home/mylogfolder

then cd to /home/mylogfolder

run

tar -cvf - *.* | gzip -c > domainname-date.tar.gz

which is compressed to 1/20th of the size

and download it and remove the one in /home/mylogfolder

that way you keep the logs and can choose a time to do the compressing when your server is least busy

jason216
09-21-2004, 08:21 PM
hi, I want to rotate all files under /usr/local/apache/domlogs/ 2 times per week.

How can I do?

its redhat with cpanel in my server.


Thanks

jason216
09-21-2004, 08:25 PM
Can anyone help me please?

Those files are very large in 2 days time.