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?


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.

  • 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'
    – artem
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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