Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to restart multiple tomcat Services under Linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to restart multiple tomcat services under Linux. I hope you will get something after reading this article. Let's discuss it together.

After modifying the configuration file of tomcat or manually manipulating database data, the cache of tomcat and redis is very serious, so it is necessary to restart tomcat frequently to release the cache, often manually.

# 1. Find the process IDps-ef of tomcat | grep tomcat# 2. Find the process ID according to the path, and then kill it one by one (after all, there will be multiple tomcat of different businesses running on one server. ) kill-9 [ID]

When you first come into contact with these commands, you will often manually type the commands and then practice deepening, over time, it feels like a waste of time (sometimes frequently modify the contents of the database).

So I wondered if I could make up a shell script to do these meaningless work for me.

Create a new file:

Touch restart.shvi restart.sh

Contents of the file:

#! / bin/bashkow=/opt/apache-tomcat-7.0.54open_acct=/opt/open_acct2echo "killing tomcat..." # find the process id of tomcat And kill ps-ef | grep-v grep | grep-I'/ opt/apache-tomcat-7.0.54\ | / opt/open_acct2' | awk'{print $2}'| sed-e "s / ^ / kill-9 / g" | sh-echo "killed tomcat" echo "starting kow tomcat..." # restart tomcat$kow/bin/startup.sh$open_acct/tomcat2/bin/startup.sh$open_acct/apache-tomcat-7.0.54/bin/startup.sh

Then save the file and add executable permissions:

Chmod + x restart.sh

Then run it directly to restart multiple tomcat commands.

Note: some of the above sed and sh commands check the document and do not quite understand what it means, but the general feeling is to cache the process ID and execute it as a shell script.

My idea is to match the deleted process I want to find according to the execution path of tomcat.

# this paragraph matches multiple different values, and can be modified to the path you want to match'/ opt/apache-tomcat-7.0.54\ | / opt/open_acct2' after reading this article, I believe you have some understanding of "how to restart multiple tomcat services under Linux". If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report