[Ilugc] Re: mv NewMail mbox ??

  • From: rsubr@xxxxxxxxxxxxxxxxxxxxxxxx (Raja Subramanian)
  • Date: Sat, 10 Apr 2004 02:08:50 +1000

Hi,

SaravanaKumar wrote:

Bharathi S wrote:
How to manually move the new mails from /var/spool/mail/$USER to
$USER's mbox ?

cat /var/spool/mail/$USER >> $USER/mbox
echo ""> /var/spool/mail/$USER


what happens when new mail arrives inbetween your 'cat' and your 'echo'
commands?  You end up clobbering it.  Were mailbox updating this easy, I
would be writing MTAs/MDAs/MUAs ;-)

Updating mail boxes requires carefull file locking to avoid simultaneous
updates (by mta/mda, mua, etc).  Add NFS with it's broken file locking
and it's a HUGE headache.

Since the OP has root access, it's best to shutdown the MTA for a few
seconds and ensure other precautions before performing this procedure.

Procmail can be put to work if the above is infeasible.

Also note,
    echo "" > mbox
creates a one byte file and creates a possibly invalid mbox.  To
truncate a file to zero bytes in bash, I typically do -
    :> filename

- Raja


Other related posts: