nohup守护进程在terminalclosures时死亡

我试图将远程服务器的内容复制到本地计算机上。 这是我正在使用的命令:

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

我对上述命令的理解是它应该创build一个守护进程nohup & ),它与我的terminal会话完全断开。 因此,我应该能够安全地closures我的terminal,让这个过程继续下去。

这个过程确实按照预期开始。 但是,如果我closures了terminal会话,该进程将不再显示在ps aux | grep rsync ps aux | grep rsync 。 这个过程显然已经死了,你可以在rsynclog中看到:

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

这是我closuresterminal的直接结果。 如果我把terminal打开几个小时,那么rsync工作正常。 但是,一旦我closures它,这个过程就会消失。

有没有人对nohup足够的了解来解释它为什么似乎不在这里工作? 我使用Windows PuTTY创buildterminal,但我也通过我的Ubuntu机器上的terminal尝试了它,并得到了相同的结果。

我尝试了一个简单的testingnohup sleep 100000 &这个DID的工作! 然而,我不清楚为什么这个守护进程在rsync死的时候继续存在。

使用screentmux 。 这不是这样做的。

我还build议长时间运行的作业screen ,但也可以使用BASH内置命令来从当前shell中删除作业。

 # help disown disown: disown [-h] [-ar] [jobspec ...] Remove jobs from current shell. Removes each JOBSPEC argument from the table of active jobs. Without any JOBSPECs, the shell uses its notion of the current job. Options: -a remove all jobs if JOBSPEC is not supplied -h mark each JOBSPEC so that SIGHUP is not sent to the job if the shell receives a SIGHUP -r remove only running jobs Exit Status: Returns success unless an invalid option or JOBSPEC is given. 

nohup不会从它的inputterminal分离进程,但sleep命令不读取任何从标准input,所以它将继续运行,而rsync读取标准input,所以当你closuresterminal时,它将从该terminal分离和rsync将接收EOF或EIO。

尝试执行nohup cat &在nohup.out中查看类似的错误。

尝试使用<dev/null 。 如果它不起作用,那么你将需要使用screen

另外检查https://unix.stackexchange.com/questions/31824/how-to-attach-terminal-to-detached-process