procmail
[Top] [All Lists]

Re: spool mail to 2 different mail directories

1997-02-14 03:27:27
On Thu, 13 Feb 1997, Stan Ryckman wrote:

At 03:51 PM 2/13/97 -0500, Pam Skillman wrote:
On Thu, 13 Feb 1997, James Beal wrote:

[snip]


1 0 * * * ( cd  /var/spool/mail/Backup ; rm -rf backup.4;mv backup.3
backup.4 ; mv backup.2 backup.3; mv backup..1 backup.2; mv today
backup.1; mkdir today ; chmod 1777 today  )  


thanks, I only have 2 more questions (yeah...so she says...:)

Hey, we've all been there... every one answer generates two new
questions :-)

Question #1:
Is there a synchronization problem between 'mv today backup.1' and
'mkdir today' where a message may be in the process of being delivered
to the spool in 'today' when you move it to backup.1???  

        I think I have answered these the wrong way round :-(. But the 
answers are here I think.

        memory says the following so I could be wrong. Given that 
procmail will make the subdirectory for you if it does not exist then we 
can say the following. Ether the directory exists and the mail will be 
delivered to the old "today" or the directory will not exist and procmail 
will make it for us. The mkdir today is actually not required but 
there to make the code look right :-).


Question(s) #2:
Also, after the 'mv' and before the 'mkdir' completes??  If it were
attempting to deliver to a non-existent directory??...what would happen
there...would the message bounce??  or attempts to deliver before the
permissions are set correctly??


        I think that the process has an inode by this time and so if its 
started writing when you start the move all is well as the procmail process 
doesn't see the move. 

Thank you again!!



:0c
{
DROPPRIVS=yes
 
:0:
/usr/spool/mail/Backup/today/$LOGNAME/.
}


I think you can lock both of these; I'm only answering because I
haven't seen another answer, and I can't test this, so if someone
says I'm wrong, you should believe them I think!  :-)

Try (with whatever continuation chars are needed; I think word wrapping
has messed this up):

  1 0 * * * ( cd  /var/spool/mail/Backup ; lockfile ./Everything.lock ;
  rm -rf backup.4;mv backup.3
  backup.4 ; mv backup.2 backup.3; mv backup..1 backup.2; mv today
  backup.1; mkdir today ; chmod 1777 today ; rm -f ./Everything.lock  )  

and

  :0c: /var/spool/mail/Backup/Everything.lock
  {
  DROPPRIVS=yes
   
  :0:
  /usr/spool/mail/Backup/today/$LOGNAME/.
  }

Also, make sure your system boot procedure manages to remove the file
/var/spool/mail/Backup/Everything.lock whenever it exists.

HOWEVER... I think what I just suggested will also allow only one
filing to Backup at a time.  If your volume is high enough to make
that unacceptable, then maybe someone else can suggest something
better.

Cheers,
Stan



James Beal -sysadmin, Phone 01954 785406 Fax 01954 785444
--------------------------------------------------------------------------
I've seen the Information SuperHighway and it is coned-off -- Steve Bell

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