Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am transferring a large amount of files from one computer to another using rsync. I am doing this by SSHing into the source computer and executing a command like this:

sudo rsync ssh --rsync-path="sudo rsync" source_dir user@host.com:dest_dir.

Even if I add nohup before this command, whenever I close out the terminal window from which I SSHed, the connection closes.

How can I have it so that my file transfer still continues when I close my SSH connection?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

The reason why nohup is not helping you is because the program works with standard IO files.

Here is' an excerpt from Wiki Page for nohup:

Note - Nohupping backgrounded jobs is typically used to avoid terminating them when logging off from a remote SSH session. A different issue that often arises in this situation is that ssh is refusing to log off ("hangs"), since it refuses to lose any data from/to the background job(s). This problem can also be overcome by redirecting all three I/O streams:

nohup ./myprogram > foo.out 2> foo.err < /dev/null & Also note that a closing SSH session does not always send a HUP signal to depending processes. Among others, this depends on whether a pseudo-terminal was allocated or not.

You can use screen for that.

Just create a screen session with: screen -S rsync then, you detach your screen with CTRL+A d

And you can disconnect from SSH

share|improve this answer
I want to add that when performing any work which will if interrupted, eg by a lost connection be problematic, then run it in a screen session. Screen is designed to protect against accidental connection loss. You can log in remotely, start screen, start your work, and if you lose connection you can re-connect to any running screen instance. Screen has got other useful functionality - capturing the session to a log file, having multiple "screens" in a single session (saving network overhead), and multiple viewers (Classroom style). Also worth mentioning that tmux is a screen alternative. –  Johan Mar 17 '13 at 8:13
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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