Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 9 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

That screen command is fine, but didn't work for my needs exactly.

This worked a lot better:

nohup rsync -va --delete ###.###.###.###:/var/www/sites/ /var/www/sites < /dev/null &
share|improve this answer

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.