linux中.nfsxxxx引起的文件无法删除
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux中.nfsxxxx引起的文件无法删除,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1870字,纯文字阅读大概需要3分钟。
内容图文
![linux中.nfsxxxx引起的文件无法删除](/upload/InfoBanner/zyjiaocheng/1141/63dba30aea784fdd9bd40c1cf52e8c31.jpg)
一个linux系统中的某个文件夹无法删除,使用ls -al查看有1个.nfsxxxx的文件无法删除。
使用lsof +D /filepath/,查看到文件被一个进程一直占用。
再使用ps -aux | grep pid,查看是一个java进程一直在占用,杀掉这个进程后,文件夹正常删除。
What is this .nfsxxxxxxxxxxxxxx file and why can’t I remove it?
Under unix, if you remove a file that a currently running process still has open, the file isn’t really removed. Once the process closes the file, the OS then removes the file handle and frees up the disk blocks. This process is complicated slightly when the file that is open and removed is on an NFS mounted filesystem. Since the process that has the file open is running on one machine (such as a workstation in your office or lab) and the files are on the file server, there has to be some way for the two machines to communicate information about this file. The way NFS does this is with the .nfsNNNN files. If you try to remove one of these file, and the file is still open, it will just reappear with a different number. So, in order to remove the file completely you must kill the process that has it open.
If you want to know what process has this file open, you can use ‘lsof .nfs1234’. Note, however, this will only work on the machine where the processes that has the file open is running. So, if your process is running on bobac and you run the lsof on some other burrow machine, you won’t see anything.
For example:
% echo test > foo
% tail -f foo
test
^Z
Suspended
% rm foo
% ls -A
.nfsB23D
% rm .nfsB23D
% ls -A
.nfsC23D
% lsof .nfsC23D
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tail 1257 robh 0r VREG 176,6 5 3000753 .nfsC23D
%
So, once you have located and killed the process that has the file open, the .nfs file will go away automatically. In the above example, when you kill the tail process, the .nfsC23D file will disappear.
The useful tools: ps, lsof
原文:https://www.cnblogs.com/lnlvinso/p/10433656.html
内容总结
以上是互联网集市为您收集整理的linux中.nfsxxxx引起的文件无法删除全部内容,希望文章能够帮你解决linux中.nfsxxxx引起的文件无法删除所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。