自动求解RM无法删除路径:设备或资源繁忙错误
我正在尝试使用 rm -rf
命令删除目录/path/to/dir
。
会发现错误
rm: cannot remove '/path/to/dir/.nfsdda293a660f276ca0000000a': Device or resource busy
不幸的是,经过一番研究,我
lsof /path/to/dir/.nfsdda293a660f276ca0000000a
,我意识到我需要在删除该文件之前找到使用此文件的过程:哪个将与该过程相关的PID返回某些内容:
COMMAND PID
python 28594
然后,我杀死PID并尝试尝试再次删除,但我仍然会收到初始错误。
如何强制脚本删除/path/to/dir
在脚本中自动删除,而无需手动干预?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这对我有用:
这将通过 /路径下的文件系统反复出现,因此请注意在大型目录树上进行操作。
一旦知道哪些进程打开文件,就可以退出这些应用程序,也可以使用杀死(1)命令杀死它们。
信用:
This worked for me:
That will recurse through the filesystem under /path, so beware doing it on large directory trees.
Once you know which processes have files open, you can exit those apps, or kill them with the kill(1) command.
Credit:
https://unix.stackexchange.com/questions/11238/how-to-get-over-device-or-resource-busy
这里有很多复杂的答案使每个人都感到困惑,请只做以下操作。
然后再试一次
例如
With so many complicated answers on here which is confusing everybody, please just do the following.
then try again
e.g.
如果 @hayden 答案对您没有帮助(毫无疑问或此类命令),此命令可以方便:
信用
In case the @Hayden answer didn't help you (returns nothing or such), this command can be handy:
credit