How to get the process ID to kill a nohup process?

前端 未结 13 1933
醉酒成梦
醉酒成梦 2020-11-27 08:53

I\'m running a nohup process on the server. When I try to kill it my putty console closes instead.

this is how I try to find the process ID:

ps -ef |         


        
13条回答
  •  攒了一身酷
    2020-11-27 09:43

    Today I met the same problem. And since it was a long time ago, I totally forgot which command I used and when. I tried three methods:

    1. Using the STIME shown in ps -ef command. This shows the time you start your process, and it's very likely that you nohup you command just before you close ssh(depends on you) . Unfortunately I don't think the latest command is the command I run using nohup, so this doesn't work for me.
    2. Second is the PPID, also shown in ps -ef command. It means Parent Process ID, the ID of process that creates the process. The ppid is 1 in ubuntu for process that using nohup to run. Then you can use ps --ppid "1" to get the list, and check TIME(the total CPU time your process use) or CMD to find the process's PID.
    3. Use lsof -i:port if the process occupy some ports, and you will get the command. Then just like the answer above, use ps -ef | grep command and you will get the PID.

    Once you find the PID of the process, then can use kill pid to terminal the process.

提交回复
热议问题