Tomcat Service Restart Script
#此脚本适用于本地安装tomcat环境, the action script restarts.
[Email protected]_clent ~]# cat restart_tomcat.sh #!/bin/bashfunction shutdown_tomcat () {#tomcat_id = ' jps | grep Boot Strap | awk ' {print '} ' tomcat_id= ' lsof-i:8080 | awk ' nr==2 ' {print-$} ' if [! $tomcat _id];thenecho "tomcat process in ${IP} is not exist." Elseecho "Shoutdown ${ip} tomcat"/bin/kill-9 $tomcat _idfi}function Start_tomcat () {echo "Start $ip Tomcat"/bin/sh/data/ tomcat/bin/catalina.sh start/usr/local/java/bin/jps}function Restart_tomcat () {Shutdown_tomcatstart_tomcat} Restart_tomcat
#此脚本限于在跳板机上使用操作Tomcat重启服务 (SSH key authentication between machines )
[[email protected]_clent ~]# cat restart_tomcat.sh #!/bin/shcat << EOF------------------------------------A Tomcat service that restarts certain IPs, with IP addresses separated------------------------------------eoffunction shutdown_tomcat () {ip=$1tomcat_id= ' ssh $ip ps -ef | grep tomcat | grep -v grep |awk ' {print $2} ' if [ ! $tomcat _id ]; thenecho "Tomcat process in ${ip} is not exist." else echo "Shutdown tomcat in ${ip}" ssh $ip "/bin/kill -9 $tomcat _id" fi}function start_tomcat () {ip=$1echo "Start tomcat in ${ip}" ssh $ip "Java_home=/usr/local/java/jdk1.7.0_80;export java_home;/bin/sh /data/tomcat/bin/startup.sh" ssh $ip "/usr/local/java/jdk1.7.0_80/bin/jps"}read -p "Please enter your IP address list [to be separated]:" pool_ip_listall_list= ' awk ' begin{list= "' $pool _ip_list '"; Split ( List,ip_list, ","); for (ip in ip_list) {PRINT&NBSP;IP_LIST[IP];} ' ' for ip in ${all_list[*]};d oshutdown_tomcat $ipstart _tomcat $ipdone
This article is from the "LINUX Super Dream" blog, make sure to keep this source http://215687833.blog.51cto.com/6724358/1890913
Tomcat Service Restart Script