[lug] Rotating Apache Log files

Greg Horne jeerygh at hotmail.com
Mon Jul 2 13:48:42 MDT 2001


Some of my sites generate many hits and the log file gets real big, manually 
deleting lines is tiring.  I'm trying to rotate my log files from various 
websites in this manner:

access_log ---------------> Todays log
07-02-01.access_log ------> Yesterdays
07-01-01.access_log ------> Day before that

Basically I will 'mv' access_log at the end of the day to a new file named 
according to the date, then restart apache thus creating access_log again 
all ready for the next day.  When I say put the date before the 'access_log' 
part i mean call the 'date' command and use it.  Like.....

-------rotate_logs---------

#!/bin/sh
TODAY='date'
WEBDIR="/home/www"

mv $WEBDIR/website/logs/access_log $WEBDIR/website/logs/$TODAY.access_log

---------------------------

Thanks in advance,
Greg

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com




More information about the LUG mailing list