Reputation: 3994
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?
Upvotes: 22
Views: 51402
Reputation: 6288
In some cases the pragmatic way can be to simply remove or rename the respective war-file, so tomcat undeploys the app.
Upvotes: 0
Reputation: 6324
Another way is to use CURL. In my case, I am on a corporate Windows machine that does not have WGET. I do have CURL though, and can use it via the GIT BASH terminal.
To list the applications running on Tomcat, I run the following (with user:password)
curl --user admin:admin http://localhost:8080/manager/text/list
Then to stop an application named "myapp"
curl --user admin:admin http://localhost:8080/manager/text/stop?path=/myapp
Upvotes: 13
Reputation: 116
I use wget
to stop and start applications.
The user in tomcat-user.xml
must have manager-script roles.
For TOMCAT 5/6:
wget "http://<user>:<password>@<servername>:<port>/manager/stop?=/<application context>" -O - -q
wget "http://<user>:<password>@<servername>:<port>/manager/start?=/<application context>" -O - -q
Since TOMCAT 7 (7.0.62 for my installation) you have to add /text/
after manager:
wget "http://<user>:<password>@<servername>:<port>/manager/text/stop?path=/<application context>" -O - -q
wget "http://<user>:<password>@<servername>:<port>/manager/text/start?path=/<application context>" -O - -q
Upvotes: 9
Reputation: 171
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.
Upvotes: 12
Reputation: 9389
There are three ways to stop tomcat application
Upvotes: 3
Reputation: 2969
The easiest method I know of is to install the Tomcat manager webapp, note the URL for stopping an application, and wget
that URL.
Upvotes: 12