On Tue, Jun 18, 2024 at 21:17:07 +0800, Jeff Peng wrote:
> After write to file with bash shell like:
> 
> echo … > file
> echo … >> file
> 
> Is it possible the file get no update instantly?

No.  Each of those commands opens the file (the first one opens it for
write, the second opens it for append), writes data, and then closes
the file.

If you really have both of those commands in your script, then you are
in fact opening and closing the file twice, which is not the most
efficient way to go.

But your speculation ("maybe there is a delay before the data actually
gets written by the kernel") is groundless.

> echo … >> dove.db
> doveadm create mailbox from dove.db
> 
> Sometimes it succeeds. Sometimes it fails.
> 
> If I add a line like this:
> 
> echo … >> dove.db
> sleep 1
> doveadm create mailbox from dove.db
> 
> It seems working now.

If the "dove.db" file is on a local file system, then your problem is
coming from something else.  Maybe there's a previous "doveadm"
command that starts something up, and that "something" isn't fully
up and running by the time your second doveadm command is executed?

If any network layers are involved, then *maybe* there's something in
one of those layers that could cause the file to be seen in a partially
written state, but even that would be highly speculative.

Reply via email to