Thursday, September 08, 2005

Apache Access Logs >> Error Logs >>

So I figured out how to do the rotate Apache logs for Access and Error on a Windows 2000 Server running Apache,, and I am now trying to figure this out running Apache on Slackware,, little different beast ... So for now I am doing the following to cure the size issue for the Access logs and Error logs which Apache generates when websites are veiwed.

I changed directories to the apache logs>>

cd /var/log/apache

then the following commands>>

mv access_log access_log.old
mv error_log error_log.old

this basically "moved" all the information from the current files and renamed them to the new
files with the .old extensions

now with the ls command you will see the new files in this directory

you need to restart apache to start creating the access and error log files again with the following commands

First cd to the apache "run" directory >> in this case

cd /usr/sbin

then run the following

apachectl graceful

this will restart apache gracefully and then you can change directories back to the /var/log/apache directory and see the new access and error logs being created.

I then "zipped" up the .old files to save space

gzip access_log.old
gzip error_log.old

I will do some more slueth work to figure out how to do this with the cron job and write files in a daily rotation, but for now this will have to do.

Well, that's my story and I am sticking to it..

biz

2 Comments:

Blogger Bubbasan said...

Check /etc/cron.daily for a logrotate script. This is a default script on Red Hat, and is configured with /etc/logrotate.conf. It requires /usr/sbin/logrotate. I'm sure you can find it online if you don't have it already.

The script looks like:

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

The conf file:

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

# keep 4 weeks worth of backlogs
rotate 4

# 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 wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

# system-specific logs may be also be configured here.


Enjoy!

Bubba

11:16 AM  
Blogger Dan Davis said...

thanks to both,, hey bubba, I like the okobojibbs that you are running as well.

I will post a link from my blog to it..


lata

9:36 AM  

Post a Comment

<< Home