#!/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"