Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!ji.Berkeley.EDU!kolding From: kolding@ji.Berkeley.EDU (Eric Koldinger) Newsgroups: comp.mail.mh Subject: Re: Here's a way to expire old messages Message-ID: <809@pasteur.Berkeley.Edu> Date: 17 Feb 88 21:33:49 GMT References: <8802102006.AA05618@hpsemc.HP.COM> Sender: news@pasteur.Berkeley.Edu Reply-To: kolding@ji.Berkeley.EDU.UUCP (Eric Koldinger) Organization: University of California, Berkeley Lines: 76 I use the following shell and sed scripts to archive my old mail. It takes everything in all my folders and compacts them into msgbox files in the same folder that they came from. It will automatically take any file older than 5 days (or other number of days if you specify it on the command line) and saves them away for posterity. sed runs on the files to remove most of the unecessary sendmail header lines. Note, this keeps the messages around as ,X (or actually #X on our systems). You need to clean these out, but this can easily be done with a shell script, or added to this one, if your system doesn't delete them automatically. -- archive shell script --- #! /bin/csh -f # Archive old messages in 'msgbox' file # Purge any messages older than $days and save them in the $msgfile file # create a $msgfile if necessary # format: # archive [n] # n - age of messages to purge after {default 5} # # errors variable is useful for debugging # Define default variables set msgfile=msgbox set errors=/dev/null set days=5 if ($#argv != 0) then set days=$1 endif folders -push +inbox > $errors foreach i (`folders -fast`) # set the prefix and uncompress the file set prefix=`mhpath +$i` if { pick +$i -before -$days -sequence archive >>& $errors } then if (-e $prefix/$msgfile.Z) then uncompress $prefix/$msgfile.Z set recompress='y' else if (-e $prefix/$msgfile) then set recompress='n' else touch $prefix/$msgfile set recompress='y' endif endif # select and pack the messages packf +$i archive -file $prefix/$msgfile >>& $errors rmm +$i archive >>& $errors sortm +$i >>& $errors sed -f ~/bin/strip.sed < $prefix/$msgfile > /tmp/archive$$ mv -f /tmp/archive$$ $prefix/$msgfile # recompress the message file if ($recompress == 'y') then compress $prefix/$msgfile endif endif end folders -pop >> $errors --- strip.sed sed commands --- /^Received:/d /^ id /d /^Message-Id:/d _ /| Eric \`o_O' kolding@ji.berkeley.edu ( ) "Gag Ack Barf" {....}!ucbvax!ji!kolding U