restart_aam_tomcat.sh 一个重启tomcat服务的脚本
#!/bin/sh
source /etc/profile;
#GUAN NAN
#tomcat_path="/*/aam_tomcat7"
#port="12000"
#Shenzhen 240
#tomcat_path="/*/aamif_tomcat7"
#port="9098"
#Online
tomcat_path="/*/aam_tomcat7"
port="10000"
#测试服务是否启动的接口地址
test_url="http://127.0.0.1:$port/aamif/rest/account/xxxnrc_adminxxx"
d_date=`date +'%Y-%m-%d %H:%M:%S'`
#测试服务是否启动的接口
content=`curl -m5 $test_url`
log="$tomcat_path/logs/restart_aam_tomcat.log"
echo "======>restart AAM at $d_date" >> $log
pid=`ps aux|grep $tomcat_path|grep -v grep|grep -v restart_aam_tomcat.sh|awk '{ print $2}'`
echo "pid=$pid" >> $log
if [[ $pid > 0 ]];then
echo "old pid: $pid and restart tomcat server..." >> $log
kill -9 $pid
else
echo "server not start!" >> $log
fi;
$tomcat_path/bin/startup.sh
sleep 60
if [[ "$content" =~ "result" ]]; then
echo "restart success!" >> $log
else
echo "restart failed!" >> $log
fi;
pid=`ps aux|grep $tomcat_path|grep -v grep|grep -v restart_aam_tomcat.sh|awk '{ print $2}'`
echo "current pid is $pid" >> $log
echo "" >> $log