shutdown.bat
脚本双击运行会结束使用了端口9900的程序,端口值根据需要自行修改
@echo off
setlocal enabledelayedexpansion
set "port=9900"
for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do (
if "%%e%" == "" (
set pid=%%d
) else (
set pid=%%e
)
echo !pid!
taskkill /f /pid !pid!
)
::pause
shutdown.sh
sh执行脚本会结束绑定了端口8082的程序,端口值根据需要自行修改
#!/bin/bash
#find pid of 8082 port , kill pid
sudo kill -9 $(sudo netstat -tunlp | grep :8082 | awk '{print $7}' | awk -F '/' '{print $1}')