Subject: Re: less is for logfiles

From: Rick Troxel <[email-masked]>
Date: Mon, 4 Jul 1994 14:04:46 +0059 (EDT)

On Mon, 4 Jul 1994, Roman Czyborra wrote:

> If you never sent it to the barber shop your LOGFILE would eventually
> outgrow your disk quota.  That's why I went looking for a convenient
> tool to trim it from time to time.  I've ended up with the following

[ snip ]

> By pressing v you get to edit the file, but instead of a
> real editor I use that LESSEDIT construct which empties the file only
> if it still has the size displayed, otherwise the new messages will
> get incorporated.  Is there any other solution nicer than this?

If triggering by age rather than size will suffice, then a crontab based 
approach such as the following should do:

15 2 * * * if (-e ~/procmail.LOG) mv ~/procmail.LOG ~/procmail.LOG.OLD
-- 
Rick Troxel     [email-masked]     [email-masked]     301/496-4823
///////////////////////////////////////////////////////////////////////////
     All effort and exertion put forth by man from the fullness of his
     heart is worship, if it  is prompted  by the  highest motives and
     the will to do service to humanity.                 --Abdu'l-Baha

---

From: Roman Czyborra <[email-masked]>
Date: Mon, 4 Jul 1994 17:48:42 +0200

#!/bin/sh

	SHELL=/bin/sh
	LESSEDIT='find %f -size %Bc -exec cp /dev/null {} \\;'
	export SHELL LESSEDIT

	exec less $HOME/.elm/procmail.log

Less lets you browse back and forth through your entries.  Pressing R
will read in the new entries that came in after the last update.  F
follows the continuous growth of the file, but burdens the net if used
excessively.  By pressing v you get to edit the file, but instead of a
real editor I use that LESSEDIT construct which empties the file only
if it still has the size displayed, otherwise the new messages will
get incorporated.  Is there any other solution nicer than this?

---

From: [email-masked] (David W. Tamkin)
Date: Mon, 4 Jul 1994 12:55:30 -0500 (CDT)

Roman Czyborra pointed out,

| If you never sent it to the barber shop your LOGFILE would eventually
| outgrow your disk quota.  That's why I went looking for a convenient
| tool to trim it from time to time.  ...
| 
| Is there any other solution nicer than this?

That depends on your goals.  Personally, I handle it this way: every evening
at 23:58 a cron job runs that renames each of my various logfiles (including
my procmail log), concatenates them, mails the concatenation to me, and
removes the temporary files.  I don't mail and remove the originals in case
something gets written to them between the concatenation and the removal.
In case there was something in the logfiles that I wanted to see, I can
review it in my mail; then I delete it from there.

This method of course generates one entry in my crontab log and one entry in
my procmail log, so those never are empty for more than a few moments.

For me that's indeed nicer than Roman's suggestion because it does what I
personally want: it clears old entries from the top of my logfile and then
puts them where I can take one last look at them, and it runs periodically
on its own rather than when I remember to do it.

It really all depends on the way you want to operate.

David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
[email-masked]   MCI Mail: 426-1818   +1 312 714 5610

---

From: Philip Kizer <[email-masked]>
Date: Tue, 05 Jul 1994 00:15:26 -0500

>get incorporated.  Is there any other solution nicer than this?

Interesting...personally, I use mailstat (script that should be installed
with procmail) to check my mail:

   ms() { mailstat -k $@ ~/Mail/LOG ; }
  mss() { mailstat $@ ~/Mail/LOG ; }

This way, I use 'ms' to show me the current stats but keep them in the
current logfile, and 'mss' to show them to me and clear them.  A '-o' will
show me the immediately preceding stats, but they do get overwritten at the
next 'mss'.  Then I just 'scan unseen' the appropriate folders to which
mail was delivered.

Not too elegant, but gives me the info I need (new mail info).  I definitely
think the mailstat output is much easier to read than the raw LOG file.

-philip

____________________________________________________________ Philip Kizer ___
Texas A&M CIS Operating Systems Group, Unix      fnord       [email-masked]

"Relying on the government to protect your privacy is like asking a peeping
tom to install your window blinds." -John Perry Barlow, EFF co-founder