3

If I run a process at the remote site by using ssh as follows:

nohup ssh remote sleep 100 & 

Is there a way to know the PID of sleep at remote? Trying echo $! just returns the PID of ssh at local. And, greping won't work since there are multiple sleep processes at remote.

2 Answers 2

2

You could pass a string to ssh so try

 nohup ssh remote 'sleep 100 &; echo $!' 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Little bit more what I want is nohup ssh remote 'sleep 100 & echo $!' &
0

Try the following

 nohup ssh remote 'sleep 100 > out 2> err < /dev/null & echo $!' 

1 Comment

Which does not answer the question, given that the OP told us: "there are multiple sleep processes at remote."

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.