作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
给出以下命令 lsof -i:1025
我得到:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 12345 john 11u IPv4 0xb2f4161230e18fd57 0t0 TCP localhost:foobar (LISTEN)
我正在尝试编写一个脚本来获取该 PID (12345) 并将其终止。目前我必须运行 lsof -i:1025
,获取 PID,然后运行 kill -9 12345
。
最佳答案
lsof(8)手册页说:
-t specifies that lsof should produce terse output with process
identifiers only and no header - e.g., so that the output
may be piped to kill(1). -t selects the -w option.
您可以使用 lsof -t -i:1025 | xargs kill -9
.
关于bash - 如何从 lsof 访问 PID。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33615683/
我是一名优秀的程序员,十分优秀!