Re: "nohup rsync ... >my.log &2>1" does not work



On 2008-05-18 19:26, Matthew Lincoln wrote:
I logged in through a command shell on a Linux system and entered a command:

nohup rsync ... >my.log &2>1

I expected that after the command issue the command prompt

ml@server [/]#

gets visible again.

But the ssh terminal is blocked as if I would have NOT entered "nohup".

Why is the rsync command still running in foreground although I prepended the command with "nohup" ?

Matthew

Nohup don't run things in background, it just use /dev/null as input, and
some other things, so you can logout while you run it in background.

In your case the output redirection is still done by your current shell, and
not by nohup.

To understand what I mean, do ssh othermachine df >df.out , and you will find
df.out on your local machine, not on the remote machine, while
ssh othermachine 'df > df.out' will create df.out on the remote machine.

eg, try something like:
(nohup rsync ... >my.log &2>1) &

Or just nohup rsync ... & , and use the default nohup.out

Or , just make a script, like this:
#!/bin/bash
(
rsync .......
) >my.log &2>1

And just do nohup script &

/bb
.



Relevant Pages