File moved while being written to, write continues, how is that possible?

Volker Wysk post at volker-wysk.de
Wed Mar 10 06:17:55 UTC 2021


Am Mittwoch, den 10.03.2021, 06:59 +0100 schrieb Bo Berglund:
> I have a script that runs ffmpeg to download streaming video hourly.
> It is executed as an at job at scheduled times.
> 
> Today I accidentally moved the resulting file to another folder before it was
> completely written, about 10 minutes remained to write.
> When I realized what I had done I figured that I have lost the download, but
> strangely it continued to grow in size at the new location!
> So I moved it back and the download completed and I could find no errors in the
> resulting video file.
> 
> This is really strange to me and something that would never happen on Windows...
>
> So now I wonder if this is a built-in feature of Linux generally or is it caused
> by the fact that the location of the file is on an NFS share on an Ubuntu 18
> file server?

It's a feature of Linux. Once a file is opened, the path on the (same) disk
doesn't matter. An open file (I believe) is internally accessed through its
inode, which stays the same.

AFAIK, the file even stays alive after it is deleted, until it is closed.

Bye,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20210310/9002f948/attachment.sig>


More information about the ubuntu-users mailing list