Re: [EXIM] Delete frozen messages

Pàgina inicial
Delete this message
Reply to this message
Autor: Peter Radcliffe
Data:  
A: exim-users
Assumpte: Re: [EXIM] Delete frozen messages
mark david mcCreary <mdm@???> probably said:
> You call it with a phrase that is in the Headers of the mail you want to
> delete.
> It needs to be in the same directory as the frozen messages.


Well, actually, no it doesn't - it just needs to be in your path and
your cwd needs to be the queue where the frozen messages are.

> grep -l $1 *H 2>/dev/null | sed -e 's/-H$//' | xargs exim -Mrm


Breaks nicely on split spools, isn't very portable and is horribly
inefficient.
(general sh clue: if you're piping grep output to sed in a script,
you should probably be either doing it in awk or perl).

This is what I use for nuking frozen messages, it's rather more portable
and far larger overkill. I prefer to write one slightly more powerful
script once than write a dozen to do similar jobs (and when I was
working with HUGE mail queues it was far more efficient to keep it all
in awk apart from the bits that have to be done by exim.

It should deal with any queue config (since exim does the work at
the beginning and end) and any number of queued messages (I have it
remove 50 at a time to make sure output buffers don't overflow).

The extra power comes from being able to specify the sender address
of the frozen messages to remove; the default is the null sender,
frozen error messages but you can use .\* for all or any other
extended regexp/string.

P.

-----------------------------------8<---------------------------------
#!/bin/sh

# eximclean

# Clean an exim queue of frozen bounce messages.
# Usage: $0 [address]
# pir@???

# If an option is given it is used as a regexp to match against the
# sender of the addresses to remove

PATH=/usr/local/sbin:/usr/xpg4/bin:/usr/local/bin:$PATH

# if you have a version of exim too old to use the r option, remove it.
exim -bpru | \
  awk 'BEGIN {
         rmfunct="exim -Mrm "
       }


       /^ ?[0-9].*<'"$1"'> \*\*\* frozen \*\*\*$/ {
         rmlist= rmlist " " $3; ++num
         if (num > 49) {
           if (system(rmfunct rmlist ">/dev/null") !=0) {
             print "Call to " rmfunct " " rmlist " failed."
           } else {
             total+=num; num=0; rmlist=""
           }
         }
       }


       END {
         if (num > 0) {
           if (system(rmfunct rmlist ">/dev/null") !=0) {
             print "Call to " rmfunct " " rmlist " failed."
           } else {
             total+=num
           }
         }
         if (total > 0) {
           print total " message[s] removed."
         }
       }'
-----------------------------------8<---------------------------------


-- 
pir               pir@???      pir@???      pir@???



--
*** Exim information can be found at http://www.exim.org/ ***