[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] RaQ4 log files resetting



I have a couple of virtual domains that have sub domains created using
separate <virtualhost> entries in httpd.conf

For each sub domain entry there is a line such as:

TransferLog /home/sites/site3/logs/extra-web.log

In order to ensure hits on the subdomains are logged (for some reason they
are excluded from the regular logging procedure on my RaQ4). This works
fine.

Overnight, after the regular logrotate job runs (which does not touch these
sub domain logs at all), my own script runs via cron to copy all the virtual
sites log files into one place for easy downloading (script is below).

However, these sub-domain logs are all reset to 0 bytes when they are copied
to the new location. In their current live location they are still the
correct size.  Whats going on? How can I stop this?

Cheers
Tim Skipper

Copylog script ----------------------------------------------

#!/bin/sh

# This script lives in /usr/local/bin

DESTINATION_DIR="/home/sitelogs"

[ -d $DESTINATION_DIR ] || mkdir -r $DESTINATION_DIR

# Copy httpd logs
cp -p /home/log/httpd/access.1.gz $DESTINATION_DIR/httpd-access.1.gz
cp -p /home/log/httpd/error.1.gz $DESTINATION_DIR/httpd-error.1.gz

for SITE in `ls -1 /home/sites/ | grep -v site | grep -v home`
do
   # Copy web logs
   for WEB_LOG in `ls -1 /home/sites/$SITE/logs/ | grep web.log`
   do
      cp -p /home/sites/$SITE/logs/$WEB_LOG $DESTINATION_DIR/$SITE-$WEB_LOG
   done

   # Copy ftp logs
   for FTP_LOG in `ls -1 /home/sites/$SITE/logs/ | grep ftp.log`
   do
      cp -p /home/sites/$SITE/logs/$FTP_LOG $DESTINATION_DIR/$SITE-$FTP_LOG
   done

   # Copy mail logs
   for MAIL_LOG in `ls -1 /home/sites/$SITE/logs/ | grep mail.log`
   do
      cp -p /home/sites/$SITE/logs/$MAIL_LOG
$DESTINATION_DIR/$SITE-$MAIL_LOG
   done

   # Copy rotated web logs
   for WEB_LOG in `ls -1 /home/sites/$SITE/logs/ | grep web.log.*.gz`
   do
      cp -p /home/sites/$SITE/logs/$WEB_LOG $DESTINATION_DIR/$SITE-$WEB_LOG
   done

   # Copy rotated ftp logs
   for FTP_LOG in `ls -1 /home/sites/$SITE/logs/ | grep ftp.log.*.gz`
   do
      cp -p /home/sites/$SITE/logs/$FTP_LOG $DESTINATION_DIR/$SITE-$FTP_LOG
   done

   # Copy rotated mail logs
   for MAIL_LOG in `ls -1 /home/sites/$SITE/logs | grep mail.log.*.gz`
   do
      cp -p /home/sites/$SITE/logs/$MAIL_LOG
$DESTINATION_DIR/$SITE-$MAIL_LOG
   done
done

# Tar and gZip the logs
rm $DESTINATION_DIR/logs.tar.gz
tar cvfz $DESTINATION_DIR/logs.tar.gz $DESTINATION_DIR/*.log

chown -R admin:admin $DESTINATION_DIR