Issue with nohup command

Hi everyone,
I am starting a nohup from a script (via scheduling system) as follows:
ssh user@server "nohup command & ; exit 0"
This command is not returning the command prompt untless I press "ENTER". This is causing the schedule to hang at this job and not continue with the rest of the jobs. It seems that "exit 0" command is not taking effect. Could you help please.

Thanks.

try..

ssh user@server 'nohup command &'

Nope ... still not working

try..

ssh user@server "nohup command \&"

Hi.

What about:

ssh user@server "command" &

Is it neccessary to use nohup at all?

What if the command takes hours? What if, during those hours, you have an internet service outage, causing the connection to break and the command to be killed? What if its generating tons of log spamming or something? There's good reasons to want to background the remote process instead of the local ssh connection.

What shell is being used here? If you're using bash, you might want to add a 'disown' command after the &.

Not sure I follow you.

The process on the remote server won't die if the server you started it from does. What is the parent process of the remote command? A process ID on the local server you started it from? I don't think so.

Thanks Corona688. I tested it your way and it is fine.

Thanks to everyone for your help.

It will because the TCP connection between it and the originating server will break. When it breaks, the commands still under its shells' control, i.e. not backgrounded, get killed. The ssh server does it.

So the purpose of the nohup call is to close off any way for the program to talk to the termnal(ssh waits for any process using the terminal to finish, backgrounded or not) so it can be backgrounded and left running when the ssh connection is closed early.

I'm sure I've seen where this is not the case. Perhaps I was mistaken. In any case bash has a solution as you mentioned.

Cheers.

I just did a brief experiment, opening two shell windows to a remote server. In one shell I logged in and did 'sleep 30000', which was pid 5391. In the other shell I did a loop watching /proc/5391 until it ceased to exist. Then I forced the first shell to terminate -- not a normal exit, a forced termination, which would break all connections without warning. pid 5391 was instantly killed when the connection broke. But don't take my word for it, try it yourself, maybe openssh behaves differently than whatever sshd you have.

hi . I m new to unix UNIX. In our project we are also facing a similar type of problem

can anyone explain the folloing thing in the above command
"user@server"

does the server means IP address of the server ?

Hi.

It could mean either the IP address or the hostname.

(Corona688, you were spot on by the way ... I've no idea what I did there!)