Glam Prestige Journal

Bright entertainment trends with youth appeal.

I want to copy a ~50GB folder from one server to another. This is understandably going to take quite a while, so I'd like to be able to perform it "in the background". Using the standard SCP command requires me to keep the console open. I read up about nohup, which seems like it should do the trick, but I'm struggling to get it to work. Even this seems to require the console to be left open - after typing in the command, the nohup program remains open, and if I press CTRL+C to exit it then the transfer stops. Am I misunderstanding what nohup does? Or how else can I achieve this?

3 Answers

I think would be easier to start the scp from a screen session, and once it's copying detach from the screen, any time you can go back to that screen session and check how is it going.

screen
scp foo bar

Ctrla followed by d to detach from screen

Then reattach to screen:

screen -x

The name nohup refers to the HUP signal, which was traditionally sent to processes when the (telephone-)line a terminal was connected through to a server was hung up. nohup prevents that signal from being sent, even when "hanging up" nowadays just means "closing the terminal window".

tl;dr you want to just close the terminal window (or kill the ssh connection on your side) instead of logging out of the server regularly. nohup will keep your process running, even if the terminal connection breaks in one way or another.

Well, there are few problems:

  1. If you want to run the command in the background, you need to append & to the command. Something like nohup scp file server:path/ &. It will run in background and if you will close the console, it will still transfer the file.

  2. Use sftp instead of scp. It gives much better performance results (especially for such large files). SCP is very slow. Even sftp supports batch mode: sftp -b <(echo "cd path"; echo "put file") server &

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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