#/bin/bash pid=`netstat -anp|grep 8080|awk '{printf $7}'|cut -d/ -f1` if [ ! $pid ] ;then echo "端口未被佔用" else echo "佔用端口8080進程PID爲: $pid" result=`kill -9 $pid` #echo "result = $result" rm -f test_console.log fi nohup java -jar test-console.jar >> test_console.log 2>&1 &