🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: demon.ip.developers
Article #1261

KA9Q: Keeping HISTORY to 1000 lines, but storing more that this

#1261
From: Mark Rogers
Date: Sun, 07 Jan 1996 00:00
59 lines
2861 bytes
I've been toying for a while with methods of keeping KA9Q's HISTORY file 
to a short length (eg 1000 lines), whilst keeping a large history file 
elsewhere in case I should need it. 

Using the TAIL program from SimTel/msdos/textutil/miscnix.zip, I have 
created the following batch file, which keeps HISTORY to 1000 lines, 
whilst also keeping a seperate log of articles in HISTORY.LOG. 
Additionally, when HISTORY.LOG exceeds 20000 lines, it is tailed to 
10000. 

I'm posting this here for comments, and for people to use on the 
understanding that it's not been thoroughly tested (I haven't been using 
it for long yet). 

Note that before use, the current HISTORY file should exceed 1000 lines, 
and should be renamed HISTORY.LOG. The last 1000 lines of HISTORY.LOG 
should then be used to form a new HISTORY file. Once these manual tasks 
have been done, the whole process is fully automated by HISTORY.BAT, 
which should be stored in the same directory as the HISTORY file, and 
called from DEMON.BAT (eg by inserting the following lines: 
    cd \demon\spool\news
    call history
prior to the call to net.exe).

All comments appreciated.

 -----8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-----

  @echo off
  rem HISTORY.BAT
  rem By mcr@holly.demon.co.uk, Jan 1996.
  
  rem Backup current HISTORY file
      copy HISTORY HISTORY.OLD > NUL
  rem Copy all but the first 1000 lines of HISTORY to HISTORY.LOG
      tail +1000 HISTORY >> HISTORY.LOG
  rem Remove the old HISTORY file
  rem ... and replace with the last 1000 lines of HISTORY.OLD
      tail -1000 HISTORY.OLD > HISTORY
      
  rem See if HISTORY.LOG is over 20000 lines....
      tail +20000 HISTORY.LOG > %temp%\HISTORY.$$1
      copy %temp%\HISTORY.$$1 %temp%\HISTORY.$$2 >NUL
      del %temp%\HISTORY.$$1 >NUL
      if not exist %temp%\HISTORY.$$2 goto NoLogTail
  rem It is, so tail it to 10000 lines....
      del %temp%\HISTORY.$$2 > NUL
      echo Tailing HISTORY.LOG to 10000 entries....
      tail -10000 HISTORY.LOG > HISTORY.$$$
      del HISTORY.LOG > NUL
      ren HISTORY.$$$ HISTORY.LOG
  
  :NoLogTail

Mark.
-- 
int MeaningOfLife (void) { return 42; }   // mcr@holly.demon.co.uk
function MeaningOfLife :integer; begin MeaningOfLife := 6 * 9 end;
Technical Details
Message-ID: <821075480snx@holly.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bb05,7450dc12a93670ff,start
X-Google-Attributes: gid10bb05,public
From: Mark Rogers <mcr@holly.demon.co.uk>
Subject: KA9Q: Keeping HISTORY to 1000 lines, but storing more that this
Date: 1996/01/07
Message-ID: <821075480snx@holly.demon.co.uk>
X-Deja-AN: 134781616
x-mail2news-path: relay-4.mail.demon.net!post.demon.co.uk!holly.demon.co.uk
x-nntp-posting-host: holly.demon.co.uk
organization: Unn Ltd.
newsgroups: demon.ip.developers
x-mailer: cppnews $Revision: 1.43 $