procmail
[Top] [All Lists]

Re: newbie question re: huge procmail log file

2002-02-18 10:55:58
Wolfgang suggested,

| how about an additional first recipe:
|
| :0c
| | rm -f procmaillog-$(date -d '4 months ago' +"%Y%m")

He's already followed up that the $( ) syntax doesn't work and backquotes
are necessary [actually, if the command has characters from $SHELLMETAS and
$SHELL is something that groks $( ), $( ) will work], but also

1. The action line doesn't read any of the message in, so the recipe needs
the `i' flag, or it can be done in an assignment instead:

 garbage=`rm -f procmaillog-`date -d '4 months ago' +"%Y%m"`

2. Since a log that covers a whole month needs to be deleted only once per
month, it's a waste to run date and rm for every incoming message; better to
delete the old log in a cron job once a month rather than doing it in
.procmailrc.

On a system where I didn't have cron access, I used to have a bunch of
routines in my .procmailrc to compare the month and day (that was for daily
logs; if you want monthly logs, you'd go by month and year) from the From_
postmark on every incoming message with a stored one on file.  If it
differed [as it would on the first incoming message of a new calendar day],
I cut the log, mailed it to myself (that would be the second entry in the
new log) and updated the stored date.  That way I didn't have to run date on
every incoming message.

All told, the simplest thing is just to mv the logfile to a new name.  Any
procmail process currently logging to it will follow the inode to the new
name and will continue writing to the old logfile, but the procmail process
for the next incoming message will look for a logfile by its usual name and
start a new one.  So mv it to a new name, wait a second or two in case any
incoming message is being logged to it, look it over, and edit out any
logabstracts you no longer need (or rm the whole thing if you need none of
it).



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail