linux - 用于杀死 PID 的 Shell 脚本

标签 linux shell ubuntu kill fuser

我在我的 Ubuntu 服务器上运行了一些我自己创建的进程,为了杀死它们我运行了:

sudo fuser -n tcp PORT
kill -9 PID-DISPLAYED

有什么方法可以使用 shell 脚本从端口获取 PID,然后通过运行 shell 脚本将其杀死。

谢谢。

最佳答案

fuser 可以杀死它:

 -k, --kill
     Kill processes accessing the file. Unless changed
     with -SIGNAL, SIGKILL is sent. An fuser process
     never kills itself, but may kill other fuser processes.
     The effective user ID of the process executing fuser is
     set to its real user ID before attempting to kill.

关于linux - 用于杀死 PID 的 Shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17190352/

相关文章:

ubuntu - Electron dialog.showOpenDialog() 关闭 Ubuntu 18.10 上的应用程序

Python - Node.js (V8) 运行时在此系统上不可用

linux - 在 Linux 中的单个列上进行 Grep

linux - Sigalrm(linux信号)

html - 如何使用 vala(gtk) 从 Web 获取 html 代码?

python - VIM自动补全废话

java - GLib-CRITICAL ** : g_base64_encode_step: assertion 'in != NULL' failed problems in ubuntu

linux - 如何确定路径是位于物理设备上还是位于内存中?

linux - KSH 脚本返回 249 作为退出代码

linux - linux 中的 sed 命令