Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2013 08:00:43 -0500
From:      Fbsd8 <fbsd8@a1poweruser.com>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD questions <questions@freebsd.org>
Subject:   Re: sh script & files
Message-ID:  <5124C8FB.9070605@a1poweruser.com>
In-Reply-To: <20130220134637.58d8a913.freebsd@edvax.de>
References:  <5124C428.1080909@a1poweruser.com> <20130220134637.58d8a913.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5124C8FB.9070605>