Subject: Re: xferlog question [1129] [1131]

From: [email-masked] (Patrick Salsbury)
Date: Wed, 21 Jun 1995 14:33:10 -0700 (PDT)

-> 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?
-.... 
-> B.G. Mahesh                     | Email: [email-masked]
-
	I've included below a small script that I use to truncate. I run it
through at cron job at midnight on the first of the month. (As the month turns
to a new one.) 
	My new logfile is datestamped, as in:

  -rw-------   1 root     daemon     232596 Feb 24 09:34 xferlog.to.02-01-95
  -rw-r--r--   1 root     daemon     138523 Mar  1 14:03 xferlog.to.03-01-95
  -rw-r--r--   1 root     daemon     175593 Apr  1 00:00 xferlog.to.04-01-95
  -rw-r--r--   1 root     daemon      59044 May  1 00:00 xferlog.to.05-01-95
  -rw-r--r--   1 root     daemon      57326 Jun  1 00:00 xferlog.to.06-01-95

	This makes it a BIT strange, since something like January is "up to"
Feb 1st, but other than that, it's a decent naming scheme, as it's generated
by the 'date' command, and you could run it every night if you wanted.
	(Anyone know how to tell cron "run this on the LAST day of the
month?") That would be nice, but sometimes it's the 30th, or 31st, or 28th, or
29th! I've not figured it out, yet. :-(

	Anyway, it's fairly basic, but it sends a note via email to the
ftp-admin alias (currently me) and tells me where it's stashed the new file.
It also tests to make sure the copy was successful. If not, you get a
different message in your mailbox.

	I'll eventually expand it to auto-digest and report the logs, rather
than asking me to do it, but I'm still learning Steven Nemetz's 'iisstat'
program. I got it yesterday, and it looks FANTASTIC! Check it out at:

ftp://ftp.support.lotus.com/pub/utils/InternetServices/iisstat/iisstat.html

	Hope this helps!

Pat
-------------------------------------------------------------------------------
	  Patrick Salsbury 	              SCO/IXI/Visionware           
   Sys Admin/Webmaster/Newsmaster             330 Encinal Street
	Voice: 408-429-4529	             Santa Cruz, CA 95060
     email: [email-masked]		       FAX: 408-427-5460	
		      X/UNIX/PC Integration Specialists
  Check out <A HREF="http://www.visionware.com/">The Visionware Homepage</A>

				 (snip snip)
-------------------------------------------------------------------------------
#!/bin/sh
#
# Script to truncate FTP's /var/adm/xferlog file each month and notify 
# ftp-admin of new file.
# by Patrick Salsbury - [email-masked]
#
# 02/27/95 - PGS
# 06/13/95 - Minor customizations for sioux - PGS
#
# Copy xferlog to /ftp/Logs and test for success
if /usr/bin/cp /var/adm/xferlog /ftp/Logs/xferlog.to.`/usr/bin/date +%m-%d-%y` 

#
# If it's successful...
#
then	{
# Cat /dev/null to overwrite the old xferlog
	/usr/bin/cat /dev/null > /var/adm/xferlog
# Send mail to ftp-admin announcing the move
	/usr/ucb/mail -s "Sioux FTP logfile has been moved to /ftp/Logs/" ftp-admin <<EndOfLetter

                                        `date`

Dear ftp-admin

	The FTP logfile /var/adm/xferlog has been moved to /ftp/Logs/. 

Please check it out, run reports, or whatever else your little heart desires.  

:-)
/usr/local/bin/mvlog-ftp
(Automatic update reminder program)

EndOfLetter

# Exit with status from above mail command
	exit
	}

#
# Otherwise...(if initial copy failed for some reason)
#
else	{
# Send mail to ftp-admin announcing the failure
	/usr/ucb/mail -s "Sioux FTP logfile move has failed!" ftp-admin <<EndOfLetter

                                        `date`

Dear ftp-admin

	The monthly auto-move of the FTP logfile /var/adm/xferlog has failed
for some reason.

Please check it out, and see if you can determine what went wrong. 

	You'll have to copy the file over to /ftp/Logs and edit it by hand.
	Sorry. :-(

/usr/local/bin/mvlog-ftp
(Automatic update reminder program)

EndOfLetter

# Exit with error status of 1
	exit 1
	}
fi