LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
Search this Thread
Old 09-20-2005, 08:10 AM   #1
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 16
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.
 
Old 09-21-2005, 04:58 AM   #2
rodeoclown
Member
 
Registered: Feb 2003
Posts: 44

Rep: Reputation: 15
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.
 
Old 09-21-2005, 08:06 AM   #3
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Original Poster
Rep: Reputation: 16
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
 
Old 03-24-2010, 09:21 AM   #4
TomOnTime
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP: No such file or directory...but its there!? Baix Linux - Newbie 20 07-28-2012 02:42 PM
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
/etc/rc.sysinit: /bin/awk: Text file busy teeno Linux - Software 5 02-23-2005 02:19 AM
convert error messages to text file creilar Linux - Newbie 1 05-26-2004 10:58 AM
SCP ??? where did the file go ?????? lub0 Linux - Security 3 10-07-2003 05:19 PM


All times are GMT -5. The time now is 04:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration