Linux – nohup daemon process dies when terminal is close

daemonlinuxnohuprsyncterminal

I'm trying to copy the contents of a remote server to my local computer. Here is the command that I'm using:

nohup rsync -chavP -e 'ssh -p 23' --stats user@ipaddress:~/great/stuff /volume1/code > ~/rsynclog &

My understanding of the above command is that it should be creating a daemon process (nohup &) which is wholly disconnected from my terminal session. As such, I should be able to safely close my terminal and have the process continue on its merry way.

The process does start as expected. However, if I close my terminal session, the process no longer shows up in ps aux | grep rsync. The process has obviously died as you can see in the rsynclog:

receiving incremental file list
Killed by signal 1.
rsync error: unexplained error (code 255) at rsync.c(615) [Receiver=3.0.9]

This is happening as a direct result of my closing the terminal. If I leave the terminal open for hours then rsync works fine. As soon as I close it, however, the process dies.

Does anyone know enough about nohup to explain why it doesn't seem to be working here? I'm creating the terminal using PuTTY in Windows, but I also tried it through a terminal on my ubuntu machine and got the same result.

I tried a simpler test with nohup sleep 100000 & and this DID work! However, it is unclear to me why that daemon keeps living while rsync dies…

Best Answer

Use screen or tmux. This is not the way to do this.