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