Date: 01 Apr 2000 14:39:06 -0500 From: Arcady Genkin <a.genkin@utoronto.ca> To: freebsd-questions@FreeBSD.ORG Subject: Rotating apache logs (new logs don't appear) Message-ID: <874s9ly5k5.fsf@tea.thpoon.com>
next in thread | raw e-mail | index | archive | help
I've set up a cron job to rotate apache access and error logs, but
suspect that there's a fault with my script.
It's been more than 36 hours since the last rotation, and the new logs
just don't appear (and I know that there has been traffic). Here's
what I came up with for the script:
,----
| #! /bin/sh
| # Rename current logs to have today's day of week suffix
|
| ACCESS_LOG=/var/log/apache_access_log
| ERROR_LOG=/var/log/apache_error_log
|
| # set $DAY to day of week
| DAY=`date | awk '{print $1}'`
|
| ACCESS_LOG_DAY=$ACCESS_LOG.$DAY
| ERROR_LOG_DAY=$ERROR_LOG.$DAY
|
| if [ -w $ACCESS_LOG ]
| then
| mv $ACCESS_LOG $ACCESS_LOG.tmp
| # remove all entries for local access
| egrep -v '^192\.168\.[0-9]*\.[0-9]*' $ACCESS_LOG.tmp > $ACCESS_LOG_DAY
| rm -f $ACCESS_LOG.tmp
| fi
|
| if [ -w $ERROR_LOG ]
| then
| mv $ERROR_LOG $ERROR_LOG_DAY
| mail -s "Apache errors log for $DAY" < $ERROR_LOG_DAY webmaster
| fi
`----
I suspect that perhaps apache keeps track of the log file as a file
descriptor and doesn't check if the file needs to be re-created when
trying to write to it, but I might be wrong.
Thanks for any ideas!
--
Arcady Genkin http://www.thpoon.com
Nostalgia isn't what it used to be.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?874s9ly5k5.fsf>
