linux kill端口对应的进程

 查询8101端口

netstat  -anp  |grep 8101

结果13701即为pid

tcp6       0      0 :::8101        :::*         LISTEN     13701/./yuyin-robot 

然后kill 

kill 13701

根据进程id 获取是哪个文件运行

查看进程

ps aux

打开13701进程目录,获取运行信息

cd /proc/13701

结果信息如下

101716 -r--r--r--   1 takujo takujo 0 8月   6 13:58 arch_status
101696 dr-xr-xr-x   2 takujo takujo 0 8月   6 13:58 attr
101677 -rw-r--r--   1 takujo takujo 0 8月   6 13:58 autogroup
101672 -r--------   1 takujo takujo 0 8月   6 13:58 auxv
101701 -r--r--r--   1 takujo takujo 0 8月   6 13:58 cgroup
101692 --w-------   1 takujo takujo 0 8月   6 13:58 clear_refs
101680 -r--r--r--   1 takujo takujo 0 8月   6 13:58 cmdline
101678 -rw-r--r--   1 takujo takujo 0 8月   6 13:58 comm
101707 -rw-r--r--   1 takujo takujo 0 8月   6 13:58 coredump_filter
101700 -r--r--r--   1 takujo takujo 0 8月   6 13:58 cpuset
101686 lrwxrwxrwx   1 takujo takujo 0 8月   6 13:58 cwd -> /home/takujo/桌面/dev/goproject/yuyin-robot
101671 -r--------   1 takujo takujo 0 8月   6 13:58 environ
101688 lrwxrwxrwx   1 takujo takujo 0 8月   6 13:58 exe -> /home/takujo/桌面/dev/goproject/yuyin-robot/yuyin-robot

可知exe存放在 /home/takujo/桌面/dev/goproject/yuyin-robot/yuyin-robot 这个目录下

猜你喜欢

转载自blog.csdn.net/takujo/article/details/107838008