我尝试将文件从一个目录移动到另一个目录,尽管文件已移动,但仍显示以下消息。为什么会显示“错误”?这是什么意思?什么时候发生?目录位于同一设备和分区上。该设备运行的是 Ubuntu 12.04 LTS
错误
*mv: cannot move `.' to `../new_media/press/.': Device or resource busy*
答案1
从rename(2)
手册页中:
EBUSY The rename fails because oldpath or newpath is a directory that
is in use by some process (perhaps as current working directory,
or as root directory, or because it was open for reading) or is
in use by the system (for example as mount point), while the
system considers this an error. (Note that there is no require‐
ment to return EBUSY in such cases — there is nothing wrong with
doing the rename anyway — but it is allowed to return EBUSY if
the system cannot otherwise handle such situations.)
答案2
某些进程正在使用文件。您可以使用命令“lsof”(列出打开的文件)查找哪些进程打开了哪些文件。这将返回很多打开的文件数。找到该进程后,您可以尝试将其终止。
或者,如果可以的话,重新启动计算机可能会更容易。