Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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'.
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.