1

I need to transfer file from remote Server A to server B (login to B with Terminal (putty)), but I also need to do that in background (so I can close terminal and move away). What have I tried is login to my target machine B using putty, running rsync command

rsync -azvv -e ssh root@A:/home/some_path /home/target_local_path/

But when I close putty, the process is also interrupt.

  • Have you tried nohup and &? – Scott Feb 16 '15 at 23:19
  • Can you be more specific, I not know much of Linux :( – Trinh Hoang Nhu Feb 16 '15 at 23:25
2

What about screen ?

screen - screen manager with VT100/ANSI terminal emulation

Open the terminal with screen.

Run you command and you can close the terminal.

You can then reattach if necessary.

  • I think I found a solution, ctrl z, bg, disown. Thank you guy – Trinh Hoang Nhu Feb 17 '15 at 14:19
2

A default choice for this kind of task is the olden nohup command; prefix nohup in front of your command will make it continue even after you closed the terminal:

nohup rsync -azvv -e ssh root@A:/home/some_path /home/target_local_path/

If you close the window before rsync finished, the rest of its output will be written to a file named nohup.out in the directory you started rsync.

However, in case that after you starting rsync, you also wish to do other things before logging out, append & at the end of command line to make it run in the background. You would need to redirect its output to file too in this case, since rsync would emit output that would interfere with later commands:

nohup rsync -azvv -e ssh root@A:/home/some_path /home/target_local_path/ > rsync.log 2>&1 &

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.