🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.sysadmin
Article #1003

Re: how to purge wtmp file

#1003
From: Scott Hess
Date: Wed, 09 Sep 1992 02:05
51 lines
2555 bytes
In article <18ji20INNli8@agate.berkeley.edu>,
	izumi@pinoko.berkeley.edu (Izumi Ohzawa) writes:
>In article <1992Sep8.174653.3657@essex.com> steved@essex.com writes:
>>I just noticed my /private/wtmp file today (and some other fairly
>>large files in /private/adm).  These seem to grow indefinitely....
>
>Hopefully, this post is short enough not to elicit any complaint
>from the net police.

Bitch.  Groan.  Complain, complain, complain.  Grin :-).

>It's already setup in /etc/crontab.  But it just wipes out the
>whole wtmp to zero length on the first of every months.

Actually, this is a bug.  Both /usr/adm/daily _and_ /usr/adm/monthly
perform:

    # Trim the lastlog
    cp -p /usr/adm/lastlog /usr/adm/lastlog.old
    cat /dev/null > /usr/adm/lastlog
    
    # Trim wtmp
    cp -p /usr/adm/wtmp /usr/adm/wtmp.old
    cat /dev/null > /usr/adm/wtmp

Thus, on the first day of the month, the daily script moves wtmp
to wtmp.old at 2AM, then the monthly script moves the new (empty,
if nobody new has logged in or out) wtmp over the old one ... best
solution would _probably_ be to just remove the code from the
monthly script.

>The following is a much nicer program which does the paring by
>keeping only the last N records in wtmp file.

To retain the last 2000 entries, you could probably also do something like:

    cp -p wtmp wtmp.old
    tail -72000c <wtmp.old >wtmp

"tail -Nc" delivers the last N characters of the file.  wtmp entries
are 36 bytes long (simple method to find this out - bring up a new
Terminal or Stuart window and check how much the size changed
between before and after.  Note that closing a window logs another
wtmp entry).  Thus, the above leaves 2000 or fewer records in the
wtmp file.

Later,
--
scott hess <shess@ssesco.com>       <A port is a port, of course, of course>
12901 Upton Avenue South, #326  Burnsville, MN 55337 (612) 895-1208 Anytime!
<You praise me with faint damns, the dragon growled.  -Castle Roogna, Xanth>
Technical Details
Message-ID: <SCOTT.92Sep9020540@nic.gac.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!gacvx2.gac.edu!gacvax2!scott
References: <1992Sep8.174653.3657@essex.com> <18ji20INNli8@agate.berkeley.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!gacvx2.gac.edu!gacvax2!scott
Newsgroups: comp.sys.next.sysadmin
Subject: Re: how to purge wtmp file
Message-ID: <SCOTT.92Sep9020540@nic.gac.edu>
From: scott@nic.gac.edu (Scott Hess)
Date: 9 Sep 92 02:05:40
References: <1992Sep8.174653.3657@essex.com> <18ji20INNli8@agate.berkeley.edu>
Distribution: world
Organization: Gustavus Adolphus College
Nntp-Posting-Host: nic.gac.edu
In-reply-to: izumi@pinoko.berkeley.edu's message of 9 Sep 1992 00:55:28 GMTLines: 51
Lines: 51