cp: cannot create regular file `/usr/local/bin/orange': Text file busy

来源:互联网 发布:女生做春梦 知乎 编辑:程序博客网 时间:2024/06/11 17:34

问题:

发布新版本,进行可执行文件拷贝时,遇到问题:

cp: cannot create regular file `/usr/local/bin/orange’: Text file busy

原因:

可执行(进程自身代码)被进程占用,不允许被修改,尤其是覆盖。

解决办法:

方法一
a) 重命名老的文件;
b) 拷贝新的文件;
c) 进程重启,使用新的文件;
d) 删除老的文件;

When a file is opened and locked by a process, any other process is not allowed to write into it, and in particular to completely overwrite it. But anyone (with the necessary rights) can rename it.
Thus the procedure I usually follow in this case is:
1. rename the old file
2. copy the new file, with the old name of the existing one
3. once the file is unlocked, I delete it
Note that after the step 2, the locking process still operates on the renamed file, but any new process will refers to the new one!

方法二
a) 直接删除老文件
b) 拷贝新文件
c) 重启进程

No need to wait. You can remove the file right away. The kernel will keep the old file around on disk until no one is using it.

参考:

http://www.linuxquestions.org/questions/linux-general-1/cannot-create-regular-file-text-file-busy-731644/

阅读全文
0 0
原创粉丝点击