So, you have scp
transfer (from one remote server to another), that is quite big.
And your big question is:
Does a `scp` transfer close when I close the shell?
Background & Disown the Process
- Open ssh terminal to remote server.
- Begin
scp
transfer as usual. - Background the scp process (Ctrl+Z, then the command
bg
.) - Disown the backgrounded process (
disown
). - Terminate the session (
exit
) and the process will continue to run on the remote machine.
One disadvantage to this approach is that the file descriptors for stdout and stderr will still contain references to your ssh session's tty. The terminal may hang when you try to exit because of this. You can work around this by typing ~.
to force close your ssh client (that escape sequence must follow a new line...see also ~?
). If the process you are abandoning writes to stdout or stderr, the process may exit prematurely if the tty buffer overfills.
Create a Screen Session and Detach It
GNU Screen can be used to create a remote terminal session, which can be detached and continue to run on the server after you log out of the session. You can then log back into the server at a later date and reattach to the session.
- Log into the remote server over ssh.
- Start a screen session,
screen -D -R <session_name>
. - Begin
scp
transfer as usual. - Detach the screen session with Ctrl+A then d.
- Terminate the ssh session (
exit
)
To reattach to the session:
- Log into the remote server over ssh.
- Reattach to the screen session,
screen -D -R <session_name>
إرسال تعليق