[Mailman-Users] Cleaning out messages and archives

Dennis Black dennis.black at ualberta.ca
Wed Nov 27 16:19:11 CET 2002


>===== Original Message From naboat_webmaster at naboat.org =====
>I am trying to learn how to maintain the message archives in Mailman.  How 
can I remove a specific message, range of messages, or all messages?  Is there 
a web interface to do this (would be very nice) or how does one maintain the 
amount of messages saved, etc.
>
>Thanks,
>Capn.
>
"Capn," the way I clean up one year old archives at my site is with
two scripts. The first warns the list owner about the deletion, the
second deletes any archive over a year. Unfortunately, these scripts 
only look after the 'monthly-named' ones - not the yearly, quarterly, 
(2002q4) or daily ones. I haven't had/taken the time to put the name 
variations into the scripts. Watch the linewraps. Others may do it
better, YMMV.

#!/bin/sh
# /usr/local/bin/mboxwarn
# This script finds one year old archives and sends a warning message
# to the list owner. Runs on the 15th of each month. Directory names 
# are like 2001-October. Crontab: 24 0 15 * * /usr/local/bin/mboxwarn

# constants - 
BASEDIR=/usr/local/mail/archives/private
FULLMNTH=`/usr/bin/date +"%B"`
TYEAR=`/usr/bin/date +"%Y"`
LYEAR=`expr $TYEAR - 1`

cd /usr/local/mail/lists
for LYST in `ls -1`;
do
     if [ -d ${BASEDIR}/${LYST}/${LYEAR}-${FULLMNTH} ]; then

TOBEMAILED="
The following YEAR-OLD archive will be deleted on the
first of next month. Please either retrieve it and save
it to a personal web space to make it available to your
audience, or simply do nothing and let it expire.
\n\t Mailing List:\t\t ${LYST}
\n\t Archive for:\t\t ${LYEAR}-${FULLMNTH}
\n
"

         echo "${TOBEMAILED}" | /usr/bin/mailx -s "${LYST} archive" 
${LYST}-owne
r at mailman.srv.ualberta.ca
     fi
  #  sleep 3
done
exit



### delete script



#!/bin/sh
# /usr/local/bin/mboxdel
# This script trims the 13th month off the *.mbox files for each list
# then deletes the list archive directory, and re-creates it all with
# bin/arch. Runs on the first of the month.
# Directory names are /usr/local/mail/archives/private/listname.mbox.
# Crontab: 24 0 1 * * /usr/local/bin/mboxdel

#constants
BASEDIR=/usr/local/mail/archives/private
MNTH=`/usr/bin/date +"%m"`
FULLMNTH=`/usr/bin/date +"%B"`
DAYE=`/usr/bin/date +"%d"`
TYEAR=`/usr/bin/date +"%Y"`
LYEAR=`expr $TYEAR - 1`
LMNTH=`expr $MNTH - 1`

##start in /usr/local/mail/archives/private
cd ${BASEDIR}
                                  # list of /u/l/m/archives/private/*.mbox
for DUR in `ls -d -1 *.mbox`
do
    cd ${DUR}                     # cd to ./private/*.mbox/*.mbox
    ELES=`ls *.mbox`              # should give one *.mbox file in DUR
    if [ -r ${ELES} ]; then
        echo " " > ${BASEDIR}/${DUR}/${ELES}.tmp
        LYST=`basename ${ELES} .mbox`
        /opt/freeware/bin/grepmail -h -M -d "after ${MNTH}/${DAYE}/${LYEAR}" 
${E
LES} >> ${BASEDIR}/${DUR}/${ELES}.tmp
        rm ${BASEDIR}/${DUR}/${ELES}
        mv ${BASEDIR}/${DUR}/${ELES}.tmp ${BASEDIR}/${DUR}/${ELES}
        mv ${BASEDIR}/${LYST} ${BASEDIR}/${LYST}.sav
        /home/mailman/bin/arch ${LYST}
        rm -r ${BASEDIR}/${LYST}.sav
TOBEMAILED="
The following YEAR-OLD archive has been deleted.
\n\t Mailing List:\t\t ${LYST}
\n\t Archive for:\t\t ${LYEAR} ${LMNTH}
\n
"
        echo "${TOBEMAILED}" | /usr/bin/mailx -s "${LYST} archive" 
${LYST}-owner
@mailman.srv.ualberta.ca
    fi
    cd ${BASEDIR}
    sleep 3
done
exit

Dennis.Black at UAlberta.Ca
Internet Applications, Computing and Network Services
352 General Services Building, U of A, Edmonton T6G 2H1
Ph: (780-)492-9329  Fx: (780-)492-1729
news.srv, majordomo.srv, mailman.srv




More information about the Mailman-Users mailing list