node.js 如何阻止咕噜声
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27196395/
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
How to stop Grunt
提问by jasonszhao
This question may be obvious to some, but I searched all over the internet and couldn't find the answer. I was following an install guide on Strut. How do I stop the Grunt task? I'm running Windows 7.
这个问题对某些人来说可能很明显,但我在互联网上搜索了所有内容,找不到答案。我正在遵循 Strut 上的安装指南。如何停止 Grunt 任务?我正在运行 Windows 7。
回答by adam187
If it's a task that you currently running you can stop it with
ctrl + cIf it's a task that is running in background you can find his process id (pid) with
ps aux | grep gruntand then kill it withkill {pid}
如果这是您当前正在运行的任务,则可以使用以下命令停止它
ctrl + c如果它是在后台运行的任务,您可以使用它找到他的进程 ID(pid),
ps aux | grep grunt然后使用它杀死它kill {pid}
回答by Felix Eve
One liner to kill the currently running grunt task:
一个 liner 来终止当前正在运行的 grunt 任务:
kill -9 $(ps aux | grep -v "grep" | grep grunt | awk '{print }')
Explanation:
解释:
Killis the command to end a process
Kill是结束进程的命令
The -9option is used to ensure the process is actually killedif it's stuck in a loop
该-9选项用于确保过程实际上是杀,如果它停留在循环
ps -auxlists the currently running processes
ps -aux列出当前运行的进程
grep -v "grep"excludes any lines with the word grep so we don't kill the current grep command that we are running
grep -v "grep"排除任何带有 grep 一词的行,因此我们不会终止我们正在运行的当前 grep 命令
grep gruntjust returns the line with grunt
grep grunt只返回带有 grunt 的行
And finally awk '{print $2}'returns the number in the second column that is the pid. This is what is passed to kill.
最后awk '{print $2}'返回作为 pid 的第二列中的数字。这就是传杀。
回答by Speranza
A shorter solution with a nifty trick like Felix Eve's:
一个更短的解决方案,带有像 Felix Eve 这样的巧妙技巧:
kill -9 $(ps -aux | grep "[g]runt" | awk '{print }')
The []avoids having the word 'grunt' in the grep, so it won't get accidentally deleted.
将[]其在grep的词“咕噜”,避免因此它不会意外删除。
回答by Rikki
In Powershell, run the Get-Process cmdlet, to list all processes, or with a comma-separated list to filter (wildcards work too). Its alias is ps. For example:
在 Powershell 中,运行Get-Process cmdlet以列出所有进程,或使用逗号分隔的列表进行过滤(通配符也适用)。它的别名是ps. 例如:
Get-Process grunt, node
or
或者
ps grunt, node
Once you determine the process ID (third column from the right, 'Id'), then you can use Stop-Processto end it. Its alias is kill. For example:
一旦您确定了进程 ID(从右数第三列,“Id”),您就可以使用Stop-Process来结束它。它的别名是kill. 例如:
Stop-Process 2570
or
或者
kill 2570
I'm posting this because the question and a commenter asks for a Windows, and grepdoesn't work on my Windows 10 install, and its Powershell equivalent, Select-String, doesn't satisfactorily return the full process information. Luckily Get-Process has its own filtering!
我发布这个是因为问题和评论者要求使用 Windows,并且grep在我的 Windows 10 安装上不起作用,并且它的 Powershell 等效项Select-String不能令人满意地返回完整的进程信息。幸运的是 Get-Process 有自己的过滤功能!

