procmail
[Top] [All Lists]

Re: archiving problem

1998-10-28 07:04:28
"ee" == era eriksson <era(_at_)iki(_dot_)fi> writes:

ee> On Tue, 27 Oct 1998 21:51:27 -0500 (EST), Justin Lloyd
ee> <jlloyd(_at_)harris(_dot_)com> wrote:
I am trying to set up .procmailrc to archive it's own log via a
monthly cron job.

ee> Why do you need to invoke Procmail to do this? Why not just put
ee> something like this in your crontab:

ee> 42 4 1 1 *
ee>   mv -f $HOME/Mail/procmail.log $HOME/Mail/procmail.log.`date -d "month 
ago" +%y%m`

Well, I had left something out to keep the email relatively short.  I also set
it up to archive the backup mailboxes that contain all messages before they
get filtered to various places:

   :0 hwi
   | ( for FILE in `/bin/ls $ARCHIVE/* | grep -v '\.gz'`; do  \
          mv $FILE $FILE.$YYYY-$MM                           ;\
          gzip -9 $FILE.$YYYY-$MM                            ;\
       done )

ee> I can see how it might be useful to get Procmail's idea of the value
ee> of LOGFILE, but invoking Procmail just to get that seems a bit
ee> complicated. Unless the value of LOGFILE really depends a lot on
ee> various recipes, how about putting the LOGFILE assignment in an
ee> external rc.file you can source from sh as well as INCLUDERC= from
ee> within Procmail?

:0
{
LOGDATE = `echo "$YYYY $MM" | perl -lane '--$F[1] or --$F[0] and $F[1]=12; 
printf "%d-%02d\n", @F'`
ARCHIVE = "$LOGFILE.$LOGDATE"
}

ee> (You don't need the :0 and the braces here at all.)


You are indeed correct.


LOG = "Archiving procmail log to $ARCHIVE$NL"
:0 hwi
* !
| ( mv $LOGFILE $ARCHIVE ;\
touch $LOGFILE       ;\
chmod 400 $ARCHIVE )

ee> If you already know you are -a archive, is there a specific reason
ee> you're checking for absence of headers?


The * ! was Jari's idea for disabling a rule, rather than commenting the whole
thing out.


ee> Procmail will recreate the log if it doesn't exist, so there's no real
ee> need to touch it, I believe.


I thought I had had a reason for the touch, but maybe not.  Hmm...

Thanks for your help, era.

Justin

--
Justin C. Lloyd               Harris Corporation, ISD     Voice  407/984-5558
jlloyd(_at_)harris(_dot_)com             505 John Rodes Blvd.        Fax    
407/984-6323
Unix System Administrator     Melbourne, FL  32935        Office  W3/1811B

<Prev in Thread] Current Thread [Next in Thread>