为什么命令 mv 返回消息 mv: cannot move Device or resource busy on Linux?

Pea*_*key 7 linux ubuntu-12.04

我试图将文件从一个目录移动到另一个目录,尽管文件已移动,但仍显示以下消息。为什么会显示“错误”,这是什么意思?它什么时候发生?这些目录位于同一设备和分区上。该设备运行 Ubuntu 12.04 LTS

错误

*mv: cannot move `.' to `../new_media/press/.': Device or resource busy*
Run Code Online (Sandbox Code Playgroud)

Ign*_*ams 6

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.)
Run Code Online (Sandbox Code Playgroud)

  • 如果你试图移动 `.`,那么它就是你当前的工作目录,你应该移出它。 (3认同)

ask*_*tor 6

某些进程正在使用该文件。您可以使用命令“lsof”(列出打开的文件)查找哪些进程打开了哪些文件。这将返回大量打开的文件。找到该进程后,您可以尝试杀死它。

或者如果可以的话,重新启动计算机可能会更容易。