Subject: Re: keeping only X messages

From: [email-masked] (Stephen R. van den Berg)
Date: Mon, 22 Aug 1994 20:16:31 +0200

>Two questions:
>1) I'm grabbing the message number from LASTFOLDER in a TRAP statement.
>   Is there a better way to do this?

I don't think so.  However, you can, instead of taking the count
from LASTFOLDER, simply execute the following on a periodic basis:

	rm -f _dummy_ `ls -t | sed -e '1,100 d' `

>2) Is there some way in procmail to do this?  Some obscure thing I've
>   missed?

No.

-- 
Sincerely,                                  [email-masked]
           Stephen R. van den Berg (AKA BuGless).

In this signature, the concluding three words `were left out'.

---

From: [email-masked] (David W. Tamkin)
Date: Mon, 22 Aug 1994 21:31:21 -0500 (CDT)

Stephen van den Berg suggested,

| However, you can, instead of taking the count
| from LASTFOLDER, simply execute the following on a periodic basis:

|	rm -f _dummy_ `ls -t | sed -e '1,100 d' `

Since Darren is on Netcom, where users have no cron or at access, "periodic
basis" is a problem (if he's trying to do it on his own machine, ignore what
I'm saying here).  He could put it into his .profile or .login, perhaps, but
that may be too often to run it; he could put it into his .profile or .login
with a date test to see if it had already run that day, but that may not be
often enough.  Either way it gets skipped if he doesn't log in at all on a
given calendar day.

Roman Czyborra added,

| Since you're already trapping every message I guess you could optimize
| this approach a little

|	:
|	^^From high-volume-list
|	{	MAILDIR=list
|		:0c:
|		.
|		HOST=`rm -f \`expr \\\`basename $LASTFOLDER\\\` - 100\``
|	}

Maybe taking a clue from Stephen's suggestion, could we simplify the
assignment of HOST to this?

		HOST=`rm -f \`ls -t \| tail +101\``

or, to make it easier to type,

		GONERS=`ls -t | tail +101`
		HOST=`rm -f $GONERS`

To make it rarer, perhaps we can add a wc test and get this:

	:
	^From busy list
	{
		MAILDIR=list

		:0c
		.

		LOCKFILE=trimming.lock

		:0
		* ? test `echo * | wc -w` -ge 125
		{
			GONERS=`ls -t | tail +101`
			HOST=`rm -f $GONERS`
		# Exiting procmail does clear up that lockfile, doesn't it?
		}
		:E
		{
			HOST=outahere
		}
	}

wc would run every time a message came in from the list, but ls, tail,
and rm would run only after every twenty-fifth arrival.

Darren had originally written,

> The only way I've figured out how to do this is to write a program
> that runs every 25 messages, does a count a removes the older
> messages.  This would be much easier if I count deleted messages.

I'm still baffled about that one; how can one count deleted messages?

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