Tomcat Service Restart Script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.