问题
我一般遇到这种情况,是在进行rm -rf dir还未结束的时候,ctrl+C取消了。再次进行rm -rf 的时候就会出现这种情况无法删除了:
rm: cannot remove ‘2021-09-23/.nfs0000000680da307e0000074e’: Device or resource busy
rm: cannot remove ‘2021-09-23/.nfs000000069ce7333000000752’: Device or resource busy
解决办法
执行lsof命令查看哪些程序在用这个目录
lsof +d <dir>
显示如下:
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1005/gvfs Output information may be incomplete. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 428434 root 7w REG 0,45 0 28373237765 2021-09-23/.nfs000000069b2d400500000756 java 428434 root 8w REG 0,45 33591 28402851925 2021-09-23/.nfs000000069cf1205500000757 java 428434 root 9w REG 0,45 0 28402851926 2021-09-23/.nfs000000069cf1205600000758 java 457674 root 7w REG 0,45 16447 28402201392 2021-09-23/.nfs000000069ce7333000000752 java 457674 root 8w REG 0,45 1837922 27931586686 2021-09-23/.nfs0000000680da307e0000074e
然后kill掉这些进程
kill -9 428434 457674
生活不止眼前的苟且,还有诗和远方
本文链接: https://dxsm.github.io/p/jie-jue-linux-device-or-resource-busy-wen-ti.html
版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0许可协议。转载请注明出处!