[lug] Rotating Apache Log files
Hugh Brown
hugh at vecna.com
Mon Jul 2 14:04:33 MDT 2001
man logrotate
Someone has already done much of the work for you.
You might also name the files 2001-07-28.... lexical ordering is the same
as ordering by date in that format.
Hugh
"Greg Horne"
>
> 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
More information about the LUG
mailing list