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
try:
rsync ... >my.log 2>&1 &
--
Luuk
nohup rsync ... >my.log &2>1 &
That way, the process is started in background
or you can stop the running process with Ctrl+Z and then resume it
in background with bg <jobnumber>
Greets
Chris
Two problems:
"nohup" does not put jobs into the background automatically.
So to get back the prompt you need to add '&' at the end of
the command line.
nohup currently doesn't close stdin, so your session may hang
when you attempt to log out. This is fixed in the next version
of the POSIX/SUS (and I believe Gnu nohup already), but it
can't hurt to make sure.
So you should run this command as:
nohup rsync ... </dev/null &
There is no need to redirect either stdout or stderr, as
nohup will do that for you, to the file ./nohup.out. But
if you want to redirect the output yourself, please note
the correct syntax is "... 2>&1" and not "... &2>1".
Hope this helps!
-Wayne
Try running it in the background... &
>
> 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" ?
Because nohup doesn't put it into the background, you'd still need & for
that.
nohup rsync ... >my.log 2>&1 &
Bye, Jojo
nohup does not run commands in the background.
"man nohup" will tell you what it does.
Robert
First of all: You mean 2>&1, right?
> 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" ?
Do you use the GNU version of hangup or something your shell has
builtin? The behaviour of GNU's hangup is not to spawn a seperate
process, but I don't know about the other implementations.
If you explicitly want to spawn a process, do so:
nohup rsync ... &
Recognize the ampersand at the end of the rsync-command.
Also, your redirection >my.log 2>&1 won't work as expected, because
nohup writes output to a file named 'nohup.out'.
Instead of nohup, you can also use screen with its detach and reattach
features.
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
Couple of problems here...
>nohup rsync ... >my.log &2>1
nohup does not put a command into the background, & does
&2>1 will create a file called 1
I think what you are looking for is something like:
nohup rsync <rsync options> >my.log 2>&1 &
Scott McMillan
First of all: You mean 2>&1, right?
> 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" ?
Do you use the GNU version of hangup or something your shell has
> I expected that after the command issue the command prompt
> But the ssh terminal is blocked as if I would have NOT entered "nohup".
nohup doesn't run the command in the backgound, but it stops the script
from exiting when you log out of the shell.
Try:
nohup rsync ... >my.log 2>&1 &
2>&1 redirects stderr to the same place stdout is going
the & at the end puts the command in the background.
Regards,
Ian.
Sorry, I didn't see the &2>1 thing :-(
Yes, it is 2>&1
/bb
If you use bash, you have a syntax error. Use:
$ nohup rsync ... >my.log 2>&1 &
or quicker:
$ nohup rsync &> my.log &
see more here: http://www.tldp.org/LDP/abs/html/io-redirection.html
--
Patrick CAO HUU THIEN
email: patrick point cao_huu_thien arobase upmc point fr
gpg key ID: 1024D/58D16D27 sur pgp.mit.edu
fingerprint: D7B8 7DFB 479C A02E 48A2 383C 0005 4A33 58D1 6D27
[ snip ]
> > Why is the rsync command still running in foreground although I
> > prepended the command with "nohup" ?
>
> Do you use the GNU version of hangup or something your shell has
> builtin? The behaviour of GNU's hangup is not to spawn a seperate
> process, but I don't know about the other implementations.
>
> If you explicitly want to spawn a process, do so:
>
> nohup rsync ... &
A belated possibly-nitpick: Doesn't rsync run as a separate process
in any case? and what the ampersand does it allow the original (shell)
process to continue without waiting for the rsync process to finish?
[ snip ]
--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.