From owner-freebsd-questions@FreeBSD.ORG Sun Dec 10 20:03:23 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B68D16A415 for ; Sun, 10 Dec 2006 20:03:23 +0000 (UTC) (envelope-from jan.grant@bristol.ac.uk) Received: from diri.bris.ac.uk (diri.bris.ac.uk [137.222.10.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 308AF43CA2 for ; Sun, 10 Dec 2006 20:02:11 +0000 (GMT) (envelope-from jan.grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk ([137.222.16.62]) by diri.bris.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1GtUt2-0004xW-KQ; Sun, 10 Dec 2006 20:03:21 +0000 Received: from cse-jg.cse.bris.ac.uk ([137.222.12.37]:55316) by mail.ilrt.bris.ac.uk with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1GtUsj-000211-3R; Sun, 10 Dec 2006 20:02:41 +0000 Date: Sun, 10 Dec 2006 20:02:40 +0000 (GMT) From: Jan Grant X-X-Sender: cmjg@tribble.ilrt.bris.ac.uk To: White Hat In-Reply-To: <20061210133927.6212.qmail@web34404.mail.mud.yahoo.com> Message-ID: <20061210200053.R61342@tribble.ilrt.bris.ac.uk> References: <20061210133927.6212.qmail@web34404.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-ILRT-MailScanner: Found to be clean X-ILRT-MailScanner-SpamCheck: not spam, SpamAssassin (score=-0.403, required 5, autolearn=disabled, ALL_TRUSTED -1.44, AWL 1.04) X-ILRT-MailScanner-From: jan.grant@bristol.ac.uk X-Spam-Status: No X-Spam-Score: -1.3 X-Spam-Level: - Cc: FreeBSD Users Questions Subject: Re: Atomic Update X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Dec 2006 20:03:23 -0000 On Sun, 10 Dec 2006, White Hat wrote: > I am not sure what the correct procedure is to do an > atomic update. > > Scenario: > > 1) Download database-1. This database is going to > replace an identically named database. Since I cannot > shut down the program that is using this database, > what would be the best way to insert the new database. > I was thinking that I could use the 'mv' command as > opposed to 'cp', but I am not sure. You don't mention what software is consuming your database file. It's true that "mv" within a filesystem is an atomic operation, it is not necessarily the case that an arbitrary program that is using the target file will notice the change; for instance, if the target program just has an open filehandle to the file, then it would need to reopen the file once the replacement had taken place. -- jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/ Tel +44 (0)117 3317661 http://ioctl.org/jan/ The Java disclaimer: values of 'anywhere' may vary between regions.