Click to See Complete Forum and Search --> : 140Mb Log file


bushka
09-18-2003, 05:18 AM
How do I roll the apache access log file?

It's currently at 140Mb which is unusable.

fatshady
09-18-2003, 05:55 AM
I periodically copy to a new file

cp /my/apache/logfile /home/mydir/serverlogcopydate

and then

cp /dev/null /my/apache/logfile


That way, I keep all the log files and know the dates they apply to. It works quite well - do it about every month or so, but i don't get much traffic (log file ussually 1.5 megs a month)

fredous5
09-18-2003, 06:23 AM
You can setup a more automated process by using logrotate in conjunction with cron, man logrotate for more info (if its installed), if not google will undoubtedly help you find it.

Fredous

bushka
09-18-2003, 08:20 AM
Thanks for the quick responses, I'm setting up logrotate and was hoping this entry to the logrotate.conf file looks correct...

"/var/log/httpd/access_log" {
rotate 5
weekly
size=20000k
sharedscripts
postrotate
/sbin/killall -HUP httpd
endscript
}

Ant comments?

fredous5
09-18-2003, 08:53 AM
i think you need a create instruction before the postrotate and as you are only rotating one log the sharedscripts is not needed, here is my script from a debian box

/var/log/apache/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/apache reload > /dev/null
endscript
}

fredous