Problem when shut/start sendmail and mailscanner

Julian Field mailscanner at ecs.soton.ac.uk
Tue Aug 20 00:42:22 IST 2002


At 22:09 19/08/2002, you wrote:
> > >And when there is only "df" files in the mqueue.in directory ?
> >
> > If there are only df files, you might as well delete them, as you certainly
> > don't have enough info to be able to deliver them.
> >
>
>This result in lost messages ... alright ?

MailScanner is not capable of leaving df files behind, unless it was killed
between creating the new one and deleting the old one. In that case the
message will have already been delivered, so you aren't actually losing any
mail, just duplicate files from a message that would otherwise be sent twice.

MailScanner always creates the new copy of the message completely (in the
outgoing queue), before it starts deleting the old files out of the
incoming queue. If it is killed at exactly the wrong moment, there is a
small chance that both the new and old file(s) will both exist at the same
time. If this happens, *and* the outgoing copy has been delivered before
MailScanner is restarted, the message will be delivered twice. This is
"behaviour by design" and is definitely not a bug.

It is carefully designed so that you cannot lose a message in the event of
a freeze/power-out/reset/kill/hang/crash occuring.

> > Here's the relevant bit:
> >
> > SENDMAIL=/opt/sendmail/current
> > QUEUE=/var/spool/mqueue
> > INQUEUE=/var/spool/mqueue.in
> > CF=$SENDMAIL/etc/sendmail.cf
> >
> > # Install everything if necessary (needed after careless Sun patching)
> > [ -x $SENDMAIL/bin/install.sendmail ] && $SENDMAIL/bin/install.sendmail
> >
> > # Make placeholders for status files
> > [ -d $SENDMAIL/var/status ]      || mkdir $SENDMAIL/var/status
> > [ -f $SENDMAIL/var/sendmail.st ] || touch $SENDMAIL/var/sendmail.st
> >
> > echo "Starting sendmail:\c"
> >
> > echo " clean up queue\c"
> > for queuedir in $QUEUE $INQUEUE
> > do
> >    cd $queuedir
> >
> >    # remove zero length qf files
> >    for qffile in qf*
> >    do
> >          if [ -r $qffile ]; then
> >                  if [ ! -s $qffile ]; then
> >                          rm -f $qffile
> >                  fi
> >          fi
> >    done
> >    # rename tf files to be qf if the qf does not exist
> >    for tffile in tf*
> >    do
> >          qffile=`echo $tffile | sed 's/t/q/'`
> >          # JKF 15/7/98 Put $qffile in quotes in case tffile = 'tf*'
> >          if [ -r $tffile -a ! -f "$qffile" ]; then
> >                  mv $tffile $qffile
> >          else
> >                  if [ -f $tffile ]; then
> >                          rm -f $tffile
> >                  fi
> >          fi
> >    done
> >    # remove df files with no corresponding qf files
> >    for dffile in df*
> >    do
> >          qffile=`echo $dffile | sed 's/d/q/'`
> >          if [ -r $dffile -a ! -f $qffile ]; then
> >                  mv $dffile `echo $dffile | sed 's/d/D/'`
> >          fi
> >    done
> >    # announce files that have been saved during disaster recovery
> >    for xffile in [A-Z]f*
> >    do
> >          if [ -f $xffile ]; then
> >                  echo " <saved mail spool $xffile>\c"
> >          fi
> >    done
> > done
> >
> > # Now actually start the damn thing...
> > #$SENDMAIL/bin/sendmail -q15m
> > #$SENDMAIL/bin/sendmail -bd -ODeliveryMode=queueonly
> > -OQueueDirectory=/var/spool/mqueue.in
> >
>
>Sorry, but I don't understood this script. Where I put it ?

Alter the first 4 lines to point at your configuration files and queues,
and merge this in to your MailScanner startup script. You will want to
change the end of the script as well, as that happens to be the right
settings for me.

You don't have to go to these lengths to clean the queue, it doesn't
actually matter very much. None of the Unix/Linux distributions I have used
do any of this. It's just what is considered "best practice" and might be
useful if you worry about old dead mqueue.in/mqueue files.
--
Julian Field                Teaching Systems Manager
jkf at ecs.soton.ac.uk         Dept. of Electronics & Computer Science
Tel. 023 8059 2817          University of Southampton
                             Southampton SO17 1BJ



More information about the MailScanner mailing list