Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wmtpx file growing

17 views
Skip to first unread message

David LAURENT

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to
Hello,

I have a problem with the following files
/var/adm/wtmp
/var/adm/wtmpx
/var/adm/utmp
/var/adm/utmpx
They can grow and fill my /var partition.

Since "rm", "cp /dev/null" don't free the space until ever body los out.
There must be way to prevent them from growing or a command to limit
their size.
Does the "limit" command applies for those files.
How can I prevent them from growing.
I understand it has something to do with user accounting and X or DT
server.
But I can't sort it out.

Thank you for any help.

David LAURENT

Doug Hughes

unread,
Feb 26, 2000, 3:00:00 AM2/26/00
to

cp /dev/null /var/adm/wtmpx will indeed work just fine and free up space
(do df -k before and after, you'll see).

However, if you want to keep any of this infomraiton, I just posted my
w/utmpx tools a week or two ago and you can split the file and archive
or throw away the stuff before the split. You can also use the showwtmpx
function to see to what all the records that are being inserted belong.
utmp and utmpx don't really grow in the same way. They are sparse files.
They will reach equilibrium at a point when the maximum number of people
are logged on at the same time. The records are re-used by subsequent
logins on the same pts/tty.


____________________________________________________________________________
Doug Hughes Engineering Network Services
System/Net Admin Auburn University
do...@eng.auburn.edu


Marcus Hildenbrand

unread,
Feb 28, 2000, 3:00:00 AM2/28/00
to
David LAURENT wrote:
>
> Hello,
>
> I have a problem with the following files
> /var/adm/wtmp
> /var/adm/wtmpx
> /var/adm/utmp
> /var/adm/utmpx
> They can grow and fill my /var partition.
>
> Since "rm", "cp /dev/null" don't free the space until ever body los out.
> There must be way to prevent them from growing or a command to limit
> their size.
> Does the "limit" command applies for those files.
> How can I prevent them from growing.
> I understand it has something to do with user accounting and X or DT
> server.
> But I can't sort it out.
>
> Thank you for any help.
>
> David LAURENT

If you don't like to loose all the information in wtmp? you could use
this script:

#!/bin/sh
#
# wtmp .truncate (/usr/adm/wtmp.truncate) -
# truncate old records off of wtmp and wtmpx
#
#
# This script was written by David Lindes, lin...@netcom.com
# (c) Copyright 1994 by David Lindes.
#
# Permission to copy this script as wanted/needed is granted,
# provided that it is distributed in its ENTIRETY, including
# this copyright notice and disclaimer, all comments, and the
# complete script. Modifications may be made to the default
# values of the TMPDIR, WDIR, KEEP and FILES variables, but any
# other modifications will be considered a violation of the
# copyright agreement.
#
# No distribution of this script should be for any monetary or
# compensatory charge without prior written consent of the
# author.
#
# The default values given were written for the Solaris 2.3
# (SunOS 5.3) operating system, and should be verified before
# use on any other operating system.
#
# NO GUARANTEE IS GRANTED AS TO THE BEHAVIOR OF THIS SCRIPT, AND
# NO WARRANTY SHALL BE ISSUED, IMPLIEDOR OTHERWISE, BY THE AUTHOR,
# BY SUN MICROSYSTEMS, OR BY ANY OTHER INDIVIDUAL OR COMPANY.
#
# USE THIS SCRIPT AT YOUR OWN RISK!!!!
#
# (Though comments for improvement are welcome at the above
# e-mail address.)


# Diagnostics:
# Arguments:
# optional - number of records to keep
# or, if negative, to skip.
# default: 60 ($KEEP)
#
# Exit codes:
# 0 - Successful completion
# 1 - No truncation needed with current $KEEP
# 2 - Error from cp detected
# 3 - Error from dd detected
#
# Notes:
# This script will make a backup of your files in $TMPDIR
# unless there is no truncation to be made, or there is an
# error and it bails out.

# Directory to store the temporary copies of the files:
# (originally /tmp)
TMPDIR=/tmp

# Directory where the real files are stored:
# (originally /var/adm)
WDIR=/var/adm

# List of files with record sizes, used for the for loop
# (originally "wtmp:36 wtmpx:372")
FILES="wtmp:36 wtmpx:372"

# Number of records to keep if not modified by argument:
# (originally 60, or $1 if argument given)
KEEP=${1:-60}


case "$KEEP" in
-*)
# set skip size for negative arguments
SKIP=`echo $KEEP | cut -c2-`
;;
+*)
# accept explicit positives
KEEP=`echo $KEEP | cut -c2-`
unset SKIP
;;
*)
unset SKIP
;;
esac

# get the proper values, since $FILES is customizable.
# these lines get the first entry in $FILES
WTMPFILE=`echo $FILES | cut -d: -f1`
WTMPSIZE=`echo $FILES | sed 's/^[^:]*:\([^ ]*\).*$/\1/'`

FILESIZE=`ls -lL $WDIR/$WTMPFILE | awk '{print$5}'`
# obtain thefilesize of w tmp
# for later calculations

NUMRECS=`expr $FILESIZE / $WTMPSIZE` # Store the size of the
# utmp file, in records

SKIP=${SKIP:-`expr $NUMRECS - $KEEP`}
# number of records to skip, based on
# $KEEP vs. number of records in the
# wtmp file.

if [ $SKIP -le 0 ]
then
exit 1 # nothing to truncate
fi

for PAIR in $FILES # Pair of filename and block size
do
FILE=`echo $PAIR | cut -d: -f1` # extract filename
IBS=`echo $PAIR | cut -d: -f2` # extract record size
cp $WDIR/$FILE $TMPDIR/$FILE # copy original to tmp

STATUS=$?
case $STATUS in
0)
;;
*)
echo "cp error #$STATUS, bailing out during $FILE." >&2
exit 2
;;
esac

if [ $SKIP -ge $NUMRECS ]
then
> $WDIR/$FILE
else
dd if=$TMPDIR/$FILE of=$WDIR/$FILE ibs=$IBS skip=$SKIP 2>
/dev/null
# do the truncation
fi

STATUS=$?
case $STATUS in
0)
;;
*)
echo "dd error#$STATUS, bailing out after $FILE." >&2
exit 3
;;
esac

done

exit 0


-Marcus

0 new messages