最近做性能測試,每次測試完成都要重啟tomcat,索引很麻煩,為此寫了一個簡單的shell腳本
#!/bin/sh
#kill tomcat pid
pidlist=`ps -ef|grep tomcat_message_8002|grep -v "grep"|awk '{print $2}'` //找到tomcat的PID號
echo "tomcat Id list :$pidlist" //顯示pid
kill -9 $pidlist //殺掉改進程
echo "KILL $pidlist:" //提示進程以及被殺掉
echo "service stop success"
echo "start tomcat"
cd /home/app/tomcat_message_8002
rm -rf work/*
cd bin
./startup.sh ;tail -f ../logs/catalina.out
~