unix中对在打开的文件,做mv操作,会影响读取吗
unix中对正在打开的文件,做mv操作,会影响读取吗?
unix打开a.txt,读出a.txt文件中的内容并打印,a.txt没有读取完毕时,执行了mv b.txt a.txt,请问执行mv操作后,读取的结果会是b的内容吗?
我在AIX上做过测试,读取a.txt时,每读取打印1行,就sleep(5)秒,在sleep的时候,进行了mv操作,发现没有影响,请问原理是什么?为什么没有影响。
------解决方案--------------------
不知道
mv是windows的move么
见笑
------解决方案--------------------
是跟进程线程有关系吗?
------解决方案--------------------
只改变了对接点的引用.你可以进行如下测试:开两个终端,对一个超大文件进行操作,一个进行vim,一个进行mv.是可以成功的.
------解决方案--------------------
这个跟Linux文件系统中inode有关。
------解决方案--------------------
别说是mv,就是你rm一个文件,如果此文件已经被另一个进程打开,正在进行读写操作,则,无论是进程1的rm操作还是进程2的读写操作,都是可以成功的。
------解决方案--------------------
lz 看看文件共享
unix打开a.txt,读出a.txt文件中的内容并打印,a.txt没有读取完毕时,执行了mv b.txt a.txt,请问执行mv操作后,读取的结果会是b的内容吗?
我在AIX上做过测试,读取a.txt时,每读取打印1行,就sleep(5)秒,在sleep的时候,进行了mv操作,发现没有影响,请问原理是什么?为什么没有影响。
unix
aix
file操作
------解决方案--------------------
不知道
mv是windows的move么
见笑
------解决方案--------------------
是跟进程线程有关系吗?
------解决方案--------------------
只改变了对接点的引用.你可以进行如下测试:开两个终端,对一个超大文件进行操作,一个进行vim,一个进行mv.是可以成功的.
Usually moving files within the same file system is not the same as copying and then removing the original. First a new link is added to the new directory then the original link is deleted. The data of file is not accessed. This is much faster than physical copy and remove the file-content. The file still has the same inode.
When moving files to a different file system, all files are copied and then all files are removed. If the copy fails (as in not enough space) none of the original files are removed and all of the copied files remain (and the volume remains full!). If the files are on one volume, an out of space condition cannot occur.
------解决方案--------------------
这个跟Linux文件系统中inode有关。
------解决方案--------------------
别说是mv,就是你rm一个文件,如果此文件已经被另一个进程打开,正在进行读写操作,则,无论是进程1的rm操作还是进程2的读写操作,都是可以成功的。
------解决方案--------------------
lz 看看文件共享