公司部署服务总是重启tomcat ,然后尝试学学shelll,初学shell脚本,就用个笨方法谢了一个tomcat重启的脚本,小记录一下,同时也留作以后备用,技术含量不高,但是是第一个完整的脚本。(有很多不标准的地方,欢迎各路大牛留言指导,勿喷。)
#!/bin/sh #tomcat restart shell script name=`echo "$1"` if [ "${name}" == "--n" ] then echo "" echo "restart--> $2 tocmat container" processid=`ps -ef | grep java | grep "$2" | awk ‘{print $2}‘` #if processid is not blank then kill it if [ "${processid}" != "" ] then echo "processid is--> ${processid}" echo "start to kill process--> $2" kill -9 ${processid} fi #start tomcat echo "starting process" echo ".." echo "...." echo "......" echo "........" echo "" "$2""bin/startup.sh" else echo "" echo "please use [--n] to define container absolute path." echo "" echo " ----for exampel: ./ex.sh --n /usr/home/tomcat_a/ " echo "" fi
时间: 2024-10-21 10:17:07