use*_*561 1 linux bash command-line-interface
我想杀死指定端口(变量)中的进程
export PORT=3030 netstat -ntlp | awk '$4~/:*${PORT}$/{gsub(/\/.*/,"",$NF);cmd="kill -9 "$NF;system(cmd)}'
但是变量 PORT 没有出现在命令中。
Tho*_*enS 5
使用 lsof 执行此任务:
PORT=3030 kill $(lsof -t -ni:$PORT)
归档时间:
13 年,9 月 前
查看次数:
2593 次
最近记录: