Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop a web application tomcat from command line

Tags:

I'm writing a bash script that automatically deploys an application to a tomcat server. How can I stop the application from bash / command line?

like image 297
Michael Küller Avatar asked Jun 18 '12 13:06

Michael Küller


People also ask

How do I stop a program from running in Tomcat?

To use Task Manager: Open Task Manager, and select More details if not already expanded. Select the Services tab. Locate and select IDM Apps Tomcat Service and right-click, then select Start, Stop, or Restart.

How do I start and stop Apache Tomcat from command line Linux?

Type in sudo service tomcat7 start and then hit Enter : You will receive the following message indicating the server is started: To stop the Tomcat server, type in sudo service tomcat7 start and then hit Enter in the original terminal window: You will receive a message indicating the Tomcat server has been stopped.


2 Answers

The easiest method I know of is to install the Tomcat manager webapp, note the URL for stopping an application, and wget that URL.

like image 88
Sam Avatar answered Oct 29 '22 13:10

Sam


Try this command-line script for managing tomcat called tomcat-manager. It requires Python, but allows you to do stuff from a Unix shell like:

$ tomcat-manager --user=admin --password=newenglandclamchowder \ > http://localhost:8080/manager/ stop /myapp 

and:

$ tomcat-manager --user=admin --password=newenglandclamchowder \ > http://localhost:8080/manager deploy /myapp ~/src/myapp/myapp.war 

Because it talks to tomcat over HTTP, it works "locally", i.e. via localhost, or from anywhere your tomcat instance is accessible.

like image 31
kotfu Avatar answered Oct 29 '22 12:10

kotfu