linux杀死java进程脚本例子(使用时换成自己的端口即可)
echo "kill start..."
PID1=$(lsof -i:8201|grep -v grep|awk '{print $2}')
PID2=$(lsof -i:8401|grep -v grep|awk '{print $2}')
PID3=$(lsof -i:8080|grep -v grep|awk '{print $2}')
PID4=$(lsof -i:8088|grep -v grep|awk '{print $2}')
if [ -z $PID1 ]; then
echo "gateway process not exist"
else
echo "gateway process id: $PID1"
kill -9 ${PID1}
echo "gateway process be killed"
fi
if [ -z $PID2 ]; then
echo "auth process not exist"
else
echo "auth process id: $PID2"
kill -9 ${PID2}
echo "auth process be killed"
fi
if [ -z $PID3 ]; then
echo "admin process not exist"
else
echo "admin process id: $PID3"
kill -9 ${PID3}
echo "admin process be killed"
fi
if [ -z $PID4 ]; then
echo "portal process not exist"
else
echo "portal process id: $PID4"
kill -9 ${PID4}
echo "portal process be killed"
fi
echo "all process be killed"