tomcat_restart.sh
- #!/bin/bash
-
- tomcat_pid=$(ps -ef | grep apache-tomcat-10.1.1 | grep -v "grep" | awk '{print $2}')
- #find tomcat pid
-
- echo "tomcat pid is:"$tomcat_pid
- #display tomcat pid
-
- kill -9 $tomcat_pid
- #kill tomcat
-
- echo "kill $tomcat_pid:"
- echo "service stop success"
- echo "start tomcat"
- cd /opt/apache-tomcat-10.1.1
- pwd
- rm -rf work/*
- cd bin
- ./startup.sh
验证:
- [root@logstash ~]# sh tomcat_restart.sh
- tomcat pid is:1932
- kill 1932:
- service stop success
- start tomcat
- /opt/apache-tomcat-10.1.1
- Using CATALINA_BASE: /opt/apache-tomcat-10.1.1
- Using CATALINA_HOME: /opt/apache-tomcat-10.1.1
- Using CATALINA_TMPDIR: /opt/apache-tomcat-10.1.1/temp
- Using JRE_HOME: /usr/local/jdk-11.0.10
- Using CLASSPATH: /opt/apache-tomcat-10.1.1/bin/bootstrap.jar:/opt/apache-tomcat-10.1.1/bin/tomcat-juli.jar
- Using CATALINA_OPTS:
- Tomcat started.
- [root@logstash ~]#
- [root@logstash ~]# netstat -antulp | grep 8080
- tcp6 0 0 :::8080 :::* LISTEN 2076/java
- [root@logstash ~]#