home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / next / sysadmin / 5093 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.4 KB

  1. Path: sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!gacvx2.gac.edu!gacvax2!scott
  2. Newsgroups: comp.sys.next.sysadmin
  3. Subject: Re: how to purge wtmp file
  4. Message-ID: <SCOTT.92Sep9020540@nic.gac.edu>
  5. From: scott@nic.gac.edu (Scott Hess)
  6. Date: 9 Sep 92 02:05:40
  7. References: <1992Sep8.174653.3657@essex.com> <18ji20INNli8@agate.berkeley.edu>
  8. Distribution: world
  9. Organization: Gustavus Adolphus College
  10. Nntp-Posting-Host: nic.gac.edu
  11. In-reply-to: izumi@pinoko.berkeley.edu's message of 9 Sep 1992 00:55:28 GMTLines: 51
  12. Lines: 51
  13.  
  14. In article <18ji20INNli8@agate.berkeley.edu>,
  15.     izumi@pinoko.berkeley.edu (Izumi Ohzawa) writes:
  16. >In article <1992Sep8.174653.3657@essex.com> steved@essex.com writes:
  17. >>I just noticed my /private/wtmp file today (and some other fairly
  18. >>large files in /private/adm).  These seem to grow indefinitely....
  19. >
  20. >Hopefully, this post is short enough not to elicit any complaint
  21. >from the net police.
  22.  
  23. Bitch.  Groan.  Complain, complain, complain.  Grin :-).
  24.  
  25. >It's already setup in /etc/crontab.  But it just wipes out the
  26. >whole wtmp to zero length on the first of every months.
  27.  
  28. Actually, this is a bug.  Both /usr/adm/daily _and_ /usr/adm/monthly
  29. perform:
  30.  
  31.     # Trim the lastlog
  32.     cp -p /usr/adm/lastlog /usr/adm/lastlog.old
  33.     cat /dev/null > /usr/adm/lastlog
  34.     
  35.     # Trim wtmp
  36.     cp -p /usr/adm/wtmp /usr/adm/wtmp.old
  37.     cat /dev/null > /usr/adm/wtmp
  38.  
  39. Thus, on the first day of the month, the daily script moves wtmp
  40. to wtmp.old at 2AM, then the monthly script moves the new (empty,
  41. if nobody new has logged in or out) wtmp over the old one ... best
  42. solution would _probably_ be to just remove the code from the
  43. monthly script.
  44.  
  45. >The following is a much nicer program which does the paring by
  46. >keeping only the last N records in wtmp file.
  47.  
  48. To retain the last 2000 entries, you could probably also do something like:
  49.  
  50.     cp -p wtmp wtmp.old
  51.     tail -72000c <wtmp.old >wtmp
  52.  
  53. "tail -Nc" delivers the last N characters of the file.  wtmp entries
  54. are 36 bytes long (simple method to find this out - bring up a new
  55. Terminal or Stuart window and check how much the size changed
  56. between before and after.  Note that closing a window logs another
  57. wtmp entry).  Thus, the above leaves 2000 or fewer records in the
  58. wtmp file.
  59.  
  60. Later,
  61. --
  62. scott hess <shess@ssesco.com>       <A port is a port, of course, of course>
  63. 12901 Upton Avenue South, #326  Burnsville, MN 55337 (612) 895-1208 Anytime!
  64. <You praise me with faint damns, the dragon growled.  -Castle Roogna, Xanth>
  65.