Get the PID of a process started with nohup via ssh

自古美人都是妖i 提交于 2019-12-03 03:12:46

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?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!