LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   scp text file busy error (https://www.linuxquestions.org/questions/linux-general-1/scp-text-file-busy-error-365198/)

seran 09-20-2005 08:10 AM

scp text file busy error
 
Hello,
I used to transfer some bin files from my local machine to a remote machine using scp. I copy my local file with the same name onto the remote machine. Sometimes if the bin on the remote machine(which was copied previously) is in execution scp fails with a message 'text file busy'.

[seran@zach-linux Bin]$ scp -B MyFile root@<remote machine ip>:/pluto/MyFile
scp: /pluto/MyFile: Text file busy

My scp works using batch mode, to avoid asking password everytime. I googled for this message, seriously I didnt find anything useful.

Currently what I am doing is, I do a ssh to that remote machine, kill that process and again I do scp from my machine. This is not convenient. Is there anyway to avoid this error.

rodeoclown 09-21-2005 04:58 AM

Well, the file on the remote machine is being used by an executable. You can't overwrite a file being used by another program. The only work around I would think of is to write a bash script to ssh into the machine, kill the process and then perform the scp of the file. Basically the same steps your taking now except you don't have to do it all manually.

seran 09-21-2005 08:06 AM

thanks for the reply. I got it. this is what I did.

[seran@seran seran]$ cat upload.sh
#!/bin/bash

ssh -l root <remote machine ip> pkill -9 MyFile
scp -B MyFile root@<remote machine ip>:/pluto/MyFile

TomOnTime 03-24-2010 09:21 AM

If you don't want to kill the process, you don't have to. You can rename the file and write a new file by the old name.

ssh -l root <remote machine ip> mv MyFile MyFile.still-running
scp -B MyFile root@<remote machine ip>:/pluto/MyFile

The running program is associated with the inode of the file, not the name of the file. By renaming the file, it retains the inode but frees up the name.

You can "rm MyFile.still-running" and the program will continue to run. The disk space won't be deallocated until the "use count" of the inode drops to zero. That is, until the last process using that binary exits.

For the same reason, you can eliminate the step of renaming the file and instead just delete it.
ssh -l root <remote machine ip> rm MyFile
scp -B MyFile root@<remote machine ip>:/pluto/MyFile

Understanding how inodes work in Unix is key to understanding how the Unix file systems work, and thus how to resolve problems like this. There are websites and, obviously, Unix internals books, that explain this all.

Tom
EverythingSysadmin.com

eagle-dot 08-12-2021 03:36 PM

how to resolve "scp text file busy error"
 
Usually this is a binary file ( executable) when you have an error "SCP: <xyzbin> text file busy". What you need is to kill the process associated with xyzv=bin

1) $ ps aux | grep xyzbin
2) if the process id is 12347, then run the following command
$ kill -9 12347


3) then run your scp again. It should work


scp <localfile> <login@remote_host>:<full-path> --- copy a local file to remote host

scp login@remote-host>:<full-path>/file <local-path> .... copy a file from a remote host to local host


ex. scp xyzbin test@10.0.5.185:/home/mwu/program1/bin/

scp test@10.0.5.185:/home/mwu/program1/bin/xyzbin .


All times are GMT -5. The time now is 12:41 PM.