I want to start a process using nohup on a remote machine via ssh. The problem is how to get the PID of the process started with nohup, so the \"process actually doing something
I tried the following (the local machine is Debian; the remote machine is CentOS), and it worked exactly as I think you're expecting:
~# ssh someone@somewhere 'nohup sleep 30 > out 2> err < /dev/null & echo $!' someone@somewhere's password: 14193 ~#
On the remote machine, I did ps -e, and saw this line:
14193 ? 00:00:00 sleep
So, clearly, on my local machine, the output is the PID of "sleep" executing on the remote machine.
Why are you adding bash to your command when sending it across an SSH tunnel?