Get the PID of a process started with nohup via ssh

前端 未结 1 607
迷失自我
迷失自我 2021-02-06 06:01

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

相关标签:
1条回答
  • 2021-02-06 06:31

    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?

    0 讨论(0)
提交回复
热议问题