What generates a text file busy message on Unix?

What operation generates a text file busy error? I can not say exactly.

I think this is because I am creating a temporary python script (using tempfile) and using execl from it, but I think that execl modifies the executable.

+121
unix
May 27 '13 at
source share
9 answers

This error means that some other process or user is accessing your file. Use lsof to check which other processes are using it. You can use the kill command to kill it if necessary.

+108
May 27 '13 at 12:30
source share

This time, since I saw this message, but it was distributed in System V R3 or about two decades ago. At that time, this meant that you could not change the executable file of the program during its launch.

For example, I created a make workalike called rmk , and after a while it was self-sustaining. I would launch a development version and create a new version. To make it work, you need to use a workaround:

 gcc -g -Wall -o rmk1 main.o -L. -lrmk -L/Users/jleffler/lib/64 -ljl if [ -f rmk ] ; then mv rmk rmk2 ; else true; fi ; mv rmk1 rmk 

So, to avoid problems with the "loaded text file", the assembly created a new rmk1 file, and then moved the old rmk to rmk2 (renaming was not a problem, it was disabled) and then moved the newly built rmk1 to rmk .

I have not seen an error in a modern system for a long time ... but I'm not everything that often rebuilds programs.

+29
May 27 '13 at 4:09
source share

This happens when you try to write a file that is currently being executed by the kernel, or to execute a file that is currently open for writing.

Source: http://wiki.wlug.org.nz/ETXTBSY

+11
Jul 28 '17 at 11:13
source share

In my case, I tried to execute a shell file (with the .sh extension) in a csh environment, and I was getting this error message.

just works with bash, it worked for me. for example

bash file.sh

+3
Oct 02 '17 at 12:27
source share

I don’t know the reason, but I can contribute to quick and easy work.

I just experienced this oddity in CentOS 6 after "cat> shScript.sh" (paste, ^ Z), and then edited the file in KWrite. Oddly enough, there was no visible instance (ps -ef) of script execution.

My quick work was just "cp shScript.sh shScript2.sh", after which I was able to execute shScript2.sh. Then I deleted both. Done!

+2
Jul 26 '14 at 14:10
source share

You may find that this is more common in CIFS / SMB network resources. Windows does not allow writing a file when something else opens the file, and even if the service is not Windows (it may be some other NAS product), it will probably reproduce the same behavior. Potentially, it could also be a manifestation of some problem with the NAS base, vaguely related to blocking / replication.

+2
Apr 18 '16 at 22:02
source share

If you are trying to build phpredis in a Linux box, it may take you a while to complete modifying the file permissions with the sleep command before running the file:

 chmod a+x /usr/bin/php/scripts/phpize \ && sleep 1 \ && /usr/bin/php/scripts/phpize 
+2
Oct 01 '17 at 14:15
source share

One of my impressions:

I always change the default keyboard shortcut for Chrome using reverse engineering. After the change, I forgot to close Chrome and did the following:

 sudo cp chrome /opt/google/chrome/chrome cp: cannot create regular file '/opt/google/chrome/chrome': Text file busy 

Using strace, you can find more details:

 sudo strace cp ./chrome /opt/google/chrome/chrome 2>&1 |grep 'Text file busy' open("/opt/google/chrome/chrome", O_WRONLY|O_TRUNC) = -1 ETXTBSY (Text file busy) 
+1
Mar 17 '17 at 12:53 on
source share

I came across this in PHP when using fopen() in a file, and then tried unlink() it before using fclose() on it.

Not good:

 $handle = fopen('file.txt'); // do something unlink('file.txt'); 

Good:

 $handle = fopen('file.txt'); // do something fclose($handle); unlink('file.txt'); 
0
Nov 09 '15 at 20:09
source share



All Articles