apache log directory, restarting server after rotating logs.

apache log directory, restarting server after rotating logs.

Post by xloga » Wed, 18 Mar 1998 04:00:00



Hello

I wrote in on this topic before, but I didn't go into detail like I should
have. Here is as detailed as I can get :-)

We are an ISP with virtual customers on one of our UNIX FreeBSD servers. We
are running Apache 1.2. We rotate our log files every night at midnight. The
rotating process consists of running a master.rotate script via cron that
basically calls another script to rotate our main logs, rotates the virtuals
log files, and then restarts . Here is a sample of what our master.rotate
script looks like:

#!/bin/sh
#
/var/www/rotate
/virtuals/vsite1/vsite1.com-rotate
/virtuals/vsite2/vsite2.com-rotate
/var/www/restart

The rotate script looks like:

#!/bin/sh

# Rotates server log files, without affecting users who may be
# connected to the server.

# This can be run as a cron script

DATE=`date +%d-%h`
ROOTDIR=`dirname $0`

# Add here any additional logfiles you want rotated.
LOGS='access_log error_log'

(cd $ROOTDIR/logs;

 for i in $LOGS; do
   if [ -f $i ]; then
     mv $i $i.$DATE
   fi
 done)

and the restart script looks like:

#!/bin/sh

kill -HUP `cat /usr/local/etc/httpd/logs/httpd.pid`

The problem we are having is due to customer intervention :-) Every customer
has a logs directory under their home directory. We use the TransferLog
/virtuals/vsite1/logs/www.vsite1.com-access_log in our
/var/www/conf/httpd.conf file. Anyway, all is fine and dandy until during
the day a customer removes their logs directory. Then what happens is at
midnight, after the server rotates the logs, the restart command ends the
processes, but won't restart again because the logs directory is gone from
that virtual site. It bombs out with an error that says it can't fine the
log file.

I am wondering if there is a way to have the webserver restart without
completely bombing out if a log directory is deleted?  Or is some sort of
Perl script (which others have mentioned) my only answer?

Thanks in advance

Dan

 
 
 

apache log directory, restarting server after rotating logs.

Post by David Richar » Wed, 18 Mar 1998 04:00:00



>The problem we are having is due to customer intervention :-) Every customer
>has a logs directory under their home directory. We use the TransferLog

That's the problem right there- putting the log directory under their home
directory and owned by the user is asking for trouble.

Quote:>/virtuals/vsite1/logs/www.vsite1.com-access_log in our
>/var/www/conf/httpd.conf file. Anyway, all is fine and dandy until during
>the day a customer removes their logs directory. Then what happens is at
>midnight, after the server rotates the logs, the restart command ends the
>processes, but won't restart again because the logs directory is gone from
>that virtual site. It bombs out with an error that says it can't fine the
>log file.

Well, you could use your rotate script to forcibly 'mkdir -p /path/to/logs'
for each of the customers.

Quote:>I am wondering if there is a way to have the webserver restart without
>completely bombing out if a log directory is deleted?  Or is some sort of
>Perl script (which others have mentioned) my only answer?

You could probably hack the apache sources to do this, but it's really not
an ideal solution. The 'right' solution is to not have the users able to
rename/delete the log directory at all. The next best thing is to forcibly
create the directory when you do the logfile rotation.

--
David Richards                             Ripco, since Nine*-Eighty-Three
Proud to be "anti-spam cadre #1" and the   Public Access in Chicago
5,000th least important spam-killer and    Shell/SLIP/PPP/UUCP/ISDN/Leased
minor net-abuser, by the unofficial GSUA.  (773) 665-0065 !Free Usenet/E-Mail!

 
 
 

apache log directory, restarting server after rotating logs.

Post by Marc Slemk » Wed, 18 Mar 1998 04:00:00



[...]

Quote:>The problem we are having is due to customer intervention :-) Every customer
>has a logs directory under their home directory. We use the TransferLog
>/virtuals/vsite1/logs/www.vsite1.com-access_log in our

And that is the problem.

Quote:>/var/www/conf/httpd.conf file. Anyway, all is fine and dandy until during
>the day a customer removes their logs directory. Then what happens is at
>midnight, after the server rotates the logs, the restart command ends the
>processes, but won't restart again because the logs directory is gone from
>that virtual site. It bombs out with an error that says it can't fine the
>log file.

If they can remove their logs directory, and you start Apache as root
to bind to port 80, then your customer can probably get root.

As I said before, the reason why Apache doesn't handle this gracefully
is because it would make you think that it is a good thing to be doing.
It is not.  It is documented clearly.  Either make the permissions
so the user can't remove it (ie. normally by having a higher level
directory for each vhost that the user can't write to, then a subdir
for their logs that they can read but not write then a subdir for
content that they can read and write; you can give them write access to
old logs (and the current log actually), just not the directory.

 
 
 

apache log directory, restarting server after rotating logs.

Post by Andy Rabaglia » Fri, 20 Mar 1998 04:00:00



Quote:

> We are an ISP with virtual customers on one of our UNIX FreeBSD servers. We
> are running Apache 1.2. We rotate our log files every night at midnight.

What I do is :-

* A single log file for the whole server. This means that Apache doesn't
  have all those files open all the time. Each line is tagged with the server -
  a %v entry.

* The midnight log-rotater just rotates that log, and HUPs apache.

* I then grep out each virtual server, logresolve it, compress it and store it
  in the customer stats directory.

* I then run analog over the logs, using a customised analog.conf uploaded by
  each virtual site, stored in their stats dir.

Cheers,       Andy!

 
 
 

apache log directory, restarting server after rotating logs.

Post by Michele Nicosi » Fri, 20 Mar 1998 04:00:00



> * I then grep out each virtual server, logresolve it, compress it and store it
>   in the customer stats directory.

Well,
    ho do you do it???
i havve a single apache server with  some users that loging with htpasswd file.Well
i need to make statisitcs of all the users and the time that tehy spend.I see that
apapche write name only when it logging, and then start to log with date.I need
only to calculate the time beetween the login of an user and the next login of
another user, for example.
Any info wiill help me, thanks
 
 
 

apache log directory, restarting server after rotating logs.

Post by Greg Patt » Fri, 20 Mar 1998 04:00:00



>Hello
>I am wondering if there is a way to have the webserver restart without
>completely bombing out if a log directory is deleted?  Or is some sort of
>Perl script (which others have mentioned) my only answer?

I use a program called cronolog to rotate the logs on our server daily. The URL
I have for it is http://www.nhbs.co.uk/aford/resources/apache/cronolog/ . Use
this and then you could just move the old logs via cron and not affect the
running of Apache.

                ...Greg

 
 
 

1. IPChains quits logging when logs rotate

Hi folks,

   Not specifically a firewall question, but when my log
files rotate (RH 6.1, 2.2.18), IPchains quits logging the
packets its rejecting.  There are several hosts that regularly
ping me, so I know its a logging problem.  What's in the new
log file is syslogd restart messages and the log of me
logging in and su'ing to root.  Reloading the chains script
(for other reasons) doesn't change anything.

Suggestions?

Thx, Chris
--

 Folsom, CA   95630     | I don't speak for Intel & vise versa

2. Installation problems - SCSI related?

3. How can I restart Apache 1.x server without resetting my logs

4. exports --> share in SRV4: root access of NFS FS

5. Rotating apache logs

6. Configure AttGlobal.net Account with RH8.0 Internet Druid?

7. How to rotate log files, apache and mod_ssl?

8. GNU date accepts day=00 !!!

9. Rotate and Reset Apache Logs

10. Rotating Many Logs for Virtual Domains with Apache

11. Apache Log Rotate

12. Apache logs rotate

13. Apache log rotate issue...