Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to copy a big file (about 30 Gb) in background via ssh. If I do it this way, and disconnect, it's copied well:

ssh server
# cp /file1 /file2 & >/dev/null 2>/dev/null ; disown;

But if I do this:

ssh server 'cp /file1 /file2 & >/dev/null 2>/dev/null ; disown;'

it waits until file copies. Why?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Try adding -f:

ssh -f server 'cp /file1 /file2 & >/dev/null 2>/dev/null ; disown;'

(Tested and works for me.)

From the man page:

-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm.

share|improve this answer
    
That's OK, but there is still one more problem - I can't async copy files via python-paramiko from my python code because it's behavior is like ssh binary without option '-f' –  user59178 Dec 27 '11 at 22:50
    
@user59178 - As the original question doesn't mention anything about python, I'd suggest posting this as a new question - and probably at stackoverflow.com. –  ziesemer Dec 27 '11 at 22:51
    
Anyway thanks, your answer is very useful –  user59178 Dec 27 '11 at 22:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.