0

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

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

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

谢谢。

4

2 回答 2

1

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.
于 2013-06-19T11:54:25.803 回答
0

尝试使用 killall 或 pkill,其中任何一个都会关闭您描述的参数类型的所有进程,例如:

killall firefox

将杀死所有正在运行的 Firefox 实例。

请参阅 pkill 的此链接。

于 2013-06-19T13:54:13.020 回答