File moved while being written to, write continues, how is that possible?
Bo Berglund
bo.berglund at gmail.com
Wed Mar 24 09:08:01 UTC 2021
On Wed, 10 Mar 2021 07:17:55 +0100, Volker Wysk <post at volker-wysk.de> wrote:
>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.
Today I accidentally deleted a file which was being downloaded by an at job...
With the above in mind, and since the at job still runs even though the result
file is now gone from the output folder, is there a way to resurrect it and give
it a name so it can be viewed?
The way I deleted the file was by issuing
rm inputvideo_0*
rather than
rm inputvideo_0*.mp4
Since the file being downloaded is named inputvideo_0xx.mp4.part while it is
being downloaded by youtube-dl such a command would have saved the file I
removed...
So how can I find this file and give it a name?
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list