我在服务器上运行nohup进程。当我试图杀死它,我的油灰控制台关闭。

这是我如何试图找到进程ID:

ps -ef |grep nohup 

这是杀人的命令

 kill -9 1787 787

当前回答

今天我遇到了同样的问题。因为是很久以前的事了,我完全忘了我在什么时候用了哪个命令。我尝试了三种方法:

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. 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. 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.

一旦找到进程的PID,就可以使用kill PID来终止进程。

其他回答

今天我遇到了同样的问题。因为是很久以前的事了,我完全忘了我在什么时候用了哪个命令。我尝试了三种方法:

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. 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. 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.

一旦找到进程的PID,就可以使用kill PID来终止进程。

Jobs -l应该为您提供nohup进程列表的pid。 轻轻地杀死他们。 ;)

我经常这样做。试试这个方法:

ps aux | grep script_Name

这里,script_Name可以是nohup运行的任何脚本/文件。 这个命令为您提供一个进程ID。然后使用下面的命令终止在nohup上运行的脚本。

kill -9 1787 787

这里,1787和787是问题中举例提到的进程ID。 这应该达到问题的目的。

关于失去你的油灰:通常是ps…| awk / grep / perl /…流程也会被匹配!老把戏是这样的

ps -ef | grep -i [n]ohup 

这样正则表达式搜索就不会与正则表达式搜索过程匹配!

我用下面的命令启动django服务器。

nohup manage.py runserver <localhost:port>

这适用于CentOS:

:~ ns$netstat -ntlp
:~ ns$kill -9 PID