Re: [Exim] Updating CDB databases

Top Page
Delete this message
Reply to this message
Author: Tony Finch
Date:  
To: R.Gilbert
CC: exim-users
Subject: Re: [Exim] Updating CDB databases
Richard Gilbert <R.Gilbert@???> wrote:
>
>Here are the relevant lines from mu Makefile:
>
>        cdb_encode.pl aliases | $(CDBMAKE) tmp_aliases.cdb aliases.tmp
>        cdb_encode.pl invaliases | $(CDBMAKE) tmp_invaliases.cdb invaliases.tmp
>        mv invaliases.cdb invaliases.cdb.old


At this point there's an interval where the file might not be found.

>        mv tmp_invaliases.cdb invaliases.cdb
>        mv aliases.cdb aliases.cdb.old
>        mv tmp_aliases.cdb aliases.cdb

>
>Moving the files to .old files was intended to allow any process which had
>the file open to continue, but I don't know enough about the low-level
>detail of how file handles mv commands and i-nodes behave.


You don't need to worry about that because Unix will keep a file on disk
until all the processes using it have closed it.

If you want to keep a backup copy of a file and still update it atomically,
do this:

    ln file file.old
    mv file.new file


Tony.
--
f.a.n.finch <dot@???> http://dotat.at/
VIKING: CYCLONIC BECOMING SOUTH 5 OR 6, OCCASIONALLY 7 AT FIRST, BECOMING
VARIABLE 4 FOR A TIME. OCCASIONAL RAIN. MODERATE OR GOOD.