bash 如何终止通过 SSH 启动的 Node.js 的 NOHUP 进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25152943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 11:02:57  来源:igfitidea点击:

How to kill a NOHUP process for Node.js launched via SSH

javascriptlinuxnode.jsbashssh

提问by Saravanan Rajaraman

I start node.jsserver has 3000port by nohup for background running, but now i want to stop the node.jsserver with 3000and start again with the same port. How can I stop the process?

我通过 nohup启动node.js服务器有3000 个端口用于后台运行,但现在我想node.js3000停止服务器并使用相同的端口重新启动。我怎样才能停止这个过程?

i can use this command for get the process to kill;

我可以使用这个命令来杀死进程;

ps -a","ps -ef |grep nohup

but it return;

但它回来了;

-bash: kill: (11929) - No such process

thanks

谢谢

回答by Saravanan Rajaraman

Finally i got an solution for kill the node server which is run under nohup process

最后我得到了杀死在 nohup 进程下运行的节点服务器的解决方案

by the help of

借助

start server @ background: https://stackoverflow.com/a/4018223/2616818

启动服务器@后台:https: //stackoverflow.com/a/4018223/2616818

pid: https://stackoverflow.com/a/14152730

pid:https: //stackoverflow.com/a/14152730

Kill: https://stackoverflow.com/a/8007409/2616818

杀死:https: //stackoverflow.com/a/8007409/2616818

1.Get the node process id by use

1.通过use获取节点进程id

ps -ef | grep "node"
//9500 pts/0  00:00:00 .node.bin

2.Kill the process by

2.杀死进程

kill 9500
//you can use the PID to kill if not use kill -9 pid

for advanced use forever

永远高级使用