问题
我一般遇到这种情况,是在进行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: 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掉这些进程