Tomcat服务重启脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tomcat服务重启脚本相关的知识,希望对你有一定的参考价值。
Tomcat服务重启脚本
#此脚本适用于本地安装tomcat环境,操作脚本重启。
[[email protected]_clent ~]# cat restart_tomcat.sh #!/bin/bash function shutdown_tomcat () { #tomcat_id=`jps | grep Bootstrap | awk ‘{print $1}‘` tomcat_id=`lsof -i:8080 | awk ‘NR==2‘‘{print $2}‘` if [ ! $tomcat_id ];then echo "tomcat process in ${ip} is not exist." else echo "shoutdown ${ip} tomcat" /bin/kill -9 $tomcat_id fi } function start_tomcat () { echo "start $ip tomcat" /bin/sh /data/tomcat/bin/catalina.sh start /usr/local/java/bin/jps } function restart_tomcat () { shutdown_tomcat start_tomcat } restart_tomcat
#此脚本限于在跳板机上使用操作Tomcat重启服务(机器之间做了ssh密钥认证)
[[email protected]_clent ~]# cat restart_tomcat.sh #!/bin/sh cat <<EOF ------------------------------------ 重启某些ip的tomcat服务,ip地址以,隔开 ------------------------------------ EOF function shutdown_tomcat() { ip=$1 tomcat_id=`ssh $ip ps -ef | grep tomcat | grep -v grep |awk ‘{print $2}‘` if [ ! $tomcat_id ];then echo "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=$1 echo "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 "请输入你的ip地址列表[以,隔开]:" pool_ip_list all_list=`awk ‘BEGIN{list="‘$pool_ip_list‘";split(list,ip_list,",");for(ip in ip_list){print ip_list[ip];}}‘` for ip in ${all_list[*]};do shutdown_tomcat $ip start_tomcat $ip done
本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1890913
以上是关于Tomcat服务重启脚本的主要内容,如果未能解决你的问题,请参考以下文章