<<< Date Index >>>     <<< Thread Index >>>

Re: Vanished Messages



On 13/07/04 23.47, Thomas de Klein wrote:
[snip]
> Add a cronjob like this
> 
> 1  21 1    *       *       /bin/rm -f $HOME/Mail/Trash && /bin/mv
> $HOME/Mail/Trash$(date -d -1month +\%Y\%m) $HOME/Mail/archiv/. && gzip
> $HOME/Mail/archiv/Trash$(date -d -1month +\%Y\%m) && touch
> $HOME/Mail/Trash$(date +\%Y\%m) && /bin/ln -s $HOME/Mail/Trash$(date
> +\%Y\%m) $HOME/Mail/Trash

Isn't there a race with creating the new archieve after deleting the
link to the old one? If I get the semantics of filesystems, you want

  touch $HOME/Mail/Trash$(date +\%Y\%m) && 
  /bin/ln -sf $HOME/Mail/Trash$(date +\%Y\%m) $HOME/Mail/Trash &&
  /bin/mv $HOME/Mail/Trash$(date -d -1month +\%Y\%m) \
  $HOME/Mail/archiv/. &&
  gzip $HOME/Mail/archiv/Trash$(date -d -1month +\%Y\%m)

Notice the -f for /bin/ln to remove the existing file.

This way there is no hole in time, where there is no $HOME/Mail/Trash
(and mutt or any other program may create in instead of opening the
existing file), provided that /bin/ln is able to do it atomically
(even if it is not, it is still a much shorter window, relatively).

Anyway, just a small nit.

HTH & HAND

/dossen

Attachment: pgpmELz9bGiWG.pgp
Description: PGP signature