Subject: xferlog question [1129]

From: [email-masked] (B.G. Mahesh)
Date: Fri, 13 Jan 1995 15:04:18 -0500

I am using wu-ftpd on my Sun. I want to move /var/log/xferlog to
/var/log/xferlog.0 at the end of everymonth [and xferlog.0 should be
moved to xferlog.1]. something like what we see in the case of
messages.*. Can I do such a thing?

thanks

-- 
B.G. Mahesh                     | Email: [email-masked]
Software Engineer               | Home page: http://www.fred.net/mahesh/
EVB Software Engineering, Inc.  | FAQ maintainer of alt.visa.us

---

From: Russel Kipp Jones <[email-masked]>
Date: Fri, 13 Jan 1995 17:37:16 -0500

> messages.*. Can I do such a thing?
.... 
> B.G. Mahesh                     | Email: [email-masked]

Yes it is possible.  We do that, as well as archive the file
for use on some statistics.  The perl script is included below,
it's more complicated than what you asked for, but we do
this on a nightly basis...

--------------------enclosed perl script - newxferlog.pl--------------
#! /usr/local/bin/perl 
#	@(#)newxferlog.pl 1.3 94/08/31 RKJ
#
require "ctime.pl";
$LOGDIR="/var/log/";
$LOG="xferlog";
$CPDIR="/users/projects/ftp/logs";	# copy for stats people
$DTPARM="+%y%m%d";
open(DATEPROC,"date $DTPARM|") || die "No date";
$DATE = <DATEPROC>; 		# get the date in yymmdd form
close(DATEPROC);
chop ($DATE);
$CPFILE=$CPDIR . "/" . $LOG . "." . $DATE;

die "No $LOGDIR" if ! -d $LOGDIR;
chdir ($LOGDIR) || die "can't chdir to $LOGDIR";
die "No $LOG" if ! -f $LOG;

# backup the files
-f $LOG.".1" && rename ($LOG.".1", $LOG.".2");
-f $LOG.".0" && rename ($LOG.".0", $LOG.".1");
rename ($LOG, $LOG.".0");
system "cp /dev/null $LOG && chmod 644 $LOG && /etc/chown www.wwwstats $LOG"
	 || die "Couldn't move $LOG";
sleep 40;
# set the effective uid to www
$> = (getpwnam("www"))[2] || die "Can't find user www";
$NEWLOG = $LOG.".0";
if (-d $CPDIR) {
	system "cp $NEWLOG $CPFILE && chmod 644 $CPFILE" || die "Copy to $CPFILE 
failed";
		# check the files to see if they are
		# over 182 days old, and they match
		# the logname glob; remove if so.
	opendir(RM,$CPDIR);
	while ($file = readdir(RM)) {
		if ($file =~ /$LOG\.*/) {
			(-M $file > 182) && unlink($file);
		}
	}
	closedir(RM);
}

-----------------------------------------------------------------------------
Kipp Jones ([email-masked])(http://www.cc.gatech.edu/grads/j/Kipp.Jones/)
Graduate Research Assistant                 Computing and Networking Services 
College of Computing, Room 212,  Georgia Institute of Technology, Atlanta, GA 
"Every thirty minutes, another network connects"    Anthony-Michael Rutkowski