杀掉指定端口对应进程的脚本
Shell    2018-08-31 19:07:48    5    0    0
cqc   Shell
#!/bin/bash
if [ $# -lt 1 ] ; then
  echo "usage : $0 port"
  exit -1
fi

find_pid_cmd="lsof -i:${1} -sTCP:LISTEN -F p"
pid=`${find_pid_cmd}`
if [ "${pid}" == "" ] ; then
  echo "not found service on port ${1}"
  exit -1
fi
kill ${pid#p}

while [ "`${find_pid_cmd}`" != "" ] 
do
echo "process [${pid#p}] is killing"
sleep 2
done
echo "done"


上一篇: Presto执行模型

下一篇: sed用法

文档导航