kill_name.sh文件内容

#!/bin/bash
pid=$(ps -aux|grep $1 |awk '{print $2}'|wc -l)

if [ $pid -gt 3 ];then
   ps -aux|grep $1 |grep java |awk 'NR==1{print $2}'|xargs kill -9
fi
kill_port.sh文件内容

#!/bin/bash
echo $1
pid=`sudo lsof -t -i:$1`
echo $pid
if [ $pid -ne 0 ];then
  kill -9 $pid
fi