How to send SFTP file download to background?

Try screen on machine B, start the download and detach afterwards:

On machine A:

ssh user@B

On machine B:

screen
sftp user@C
get some_file.tar.gz
Ctrl-a d
logout

Never tried but could work.

Edit: later, log back in and use screen -x to reconnect to the running session. Then, shut it down properly so that it isn't consuming the server's resources.


If you just want the "detach" feature of screen, there's a program called "dtach" that provides only that feature.


Putting the character & (ampersand) behind a command runs it in background. However, I don't know how to do it after a command has already been executed, nor do I know whether this works on remote machines.