From owner-freebsd-questions@FreeBSD.ORG Wed Feb 20 13:00:49 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1A76746C for ; Wed, 20 Feb 2013 13:00:49 +0000 (UTC) (envelope-from fbsd8@a1poweruser.com) Received: from mail-03.name-services.com (mail-03.name-services.com [69.64.155.195]) by mx1.freebsd.org (Postfix) with ESMTP id 09821ED for ; Wed, 20 Feb 2013 13:00:48 +0000 (UTC) Received: from [10.0.10.3] ([173.88.202.176]) by mail-03.name-services.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 20 Feb 2013 05:00:46 -0800 Message-ID: <5124C8FB.9070605@a1poweruser.com> Date: Wed, 20 Feb 2013 08:00:43 -0500 From: Fbsd8 User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Polytropon Subject: Re: sh script & files References: <5124C428.1080909@a1poweruser.com> <20130220134637.58d8a913.freebsd@edvax.de> In-Reply-To: <20130220134637.58d8a913.freebsd@edvax.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Feb 2013 13:00:46.0553 (UTC) FILETIME=[4C8C3490:01CE0F6A] X-Sender: fbsd8@a1poweruser.com X-Authenticated-Sender: fbsd8@a1poweruser.com X-EchoSenderHash: [fbsd8]-[a1poweruser*com] Cc: FreeBSD questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 13:00:49 -0000 Polytropon wrote: > On Wed, 20 Feb 2013 07:40:08 -0500, Fbsd8 wrote: >> # write to file >> > "${file}" >> >> I'm thinking the file is never closed so on power failure I loose the >> contents of the file. >> >> How would I code a command to close the file? > > The file is closed when the write operation has been > finished. You can use the "sync" command to flush > pending writes to the file (as writing is handled > asynchronously by the system). When the program > that writes to the file exits, it will close the > file it's writing to. This depends on the command > you're using infront of >, as the command you've > shown will simply generate a null file (file with > no actual content). > > The problem is there may be a great time lag between reading the file and the writing to the file, IE: days or months depending on how long between host reboots. I would just like to close the file right after the file gets read. Is there a way to code that?