Article View: can.usrgroup
Article #738Re: Trimming the wtmp file
From: Greg A. Woods
Date: Thu, 21 May 1992 03:26
Date: Thu, 21 May 1992 03:26
41 lines
2073 bytes
2073 bytes
In article <9205201503.AA01446@moore.com> paul@moore.com (Paul Maclauchlan) writes:
> Is there a utility that I can use to trim the contents of the wtmp
> file from the "top"?
Ideally you'd want to chop it off at a given date, but this would
require a bit of programming.
However, if you want to simply chop off some number of records from
the file, dd can do the job (example specific to SysVr3.1):
wtmprecsize=36 # this is the number 'sizeof(struct utmp)'
nchop=1000 # how many records to chop off
dd if=wtmp of=wtmp.tmp bs=$wtmprecsiz skip=$nchop
cp wtmp.tmp wtmp # must not use mv in case file is open
I presume this is simply to satisfy users of last(1).... If not, then
why not just roll over the wtmp file every day/week/month?
Instead of relying on last(1), I use a custom version of finger(1) and
something I call lastlog(1m) [since my login(1m) doesn't update
/usr/adm/lastlog]. Then the following shell function tells me when
everyone last logged in:
function lastlog
{
YearGrep="grep `date +%Y`"
if [ $# -eq 1 -a "$1" = "-a" ] ; then
YearGrep="grep -v 1969"
elif [ $# -ne 0 ] ; then
echo 'Usage: lastlog [-a]' >&2
fi
/usr/lib/acct/fwtmp < /usr/adm/lastlog.ut | $YearGrep |
oawk '{printf("%-8s %-12s %s\n", $1, $3, substr($0, 56))}'
}
Both finger(1) and lastlog(1m) can be found in robohack!~/finger.T.Z.
--
Greg A. Woods
woods@robohack.UUCP woods@Elegant.COM VE3TCP UniForum Canada & ECI
+1 416 443-1734 [home] +1 416 595-5425 [work] Toronto, Ontario; CANADA
Technical Details
Message-ID:
<1992May21.032639.7720@robohack.UUCP>Path:
arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!geac!torag!robohack!woodsReferences:
<9205201503.AA01446@moore.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1149bd,382dd2fa7fff7473 X-Google-Attributes: gid1149bd,public X-Google-ArrivalTime: 1992-05-20 18:07:34 PST Newsgroups: can.usrgroup Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!geac!torag!robohack!woods From: woods@robohack.UUCP (Greg A. Woods) Subject: Re: Trimming the wtmp file Organization: Elegant Communications Inc. References: <9205201503.AA01446@moore.com> Message-ID: <1992May21.032639.7720@robohack.UUCP> Date: Thu, 21 May 92 03:26:39 GMT Lines: 41