首页 > 代码库 > Tomcat服务重启脚本
Tomcat服务重启脚本
Tomcat服务重启脚本
#此脚本适用于本地安装tomcat环境,操作脚本重启。
[root@ansible_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密钥认证)
[root@ansible_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服务重启脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。