Tomcat Server Control with Wget and the Tomcat Manager

Tomcat Server Control with Wget and the Tomcat Manager
Tags:
* Tomcat
Using wget and the Tomcat manager, you can script remote tomcat deploys, undeploys, starts, stops, and status.
First, make sure the tomcat manager is installed and running. (see: Configuring the Tomcat Manager)
Status
Now, we can get the status of all deployed apps by running the following command:
wget http://:@:/manager/list -O – -q
for example:
wget http://admin:test1234@blojszp1:8080/manager/list -O – -q
shows the status of all applications deployed and running on this particular Tomcat instance:
/balancer:running:0:balancer
/testapp:running:0:testapp
/host-manager:running:0:/u01/app/tomcat/server/webapps/host-manager
/:running:0:ROOT
/manager:running:0:/u01/app/tomcat/server/webapps/manager
Undeploy
To undeploy an application, issue the following command:
wget “http://:@:/manager/undeploy?path=/” -O – -q
WARNING!!!!! – the undeploy function will REMOVE the application AND war file from the webapps directory.
For example:
wget “http://admin:test1234@blojszp1:8080/manager/undeploy?path=/testapp” -O – -q
OK – Undeployed application at context path /testapp
Deploy
An application can be deployed using a similar command:
wget “http://:@:/manager/deploy?path=/&war=file:” -O – -q
Where the “war=file:” is the path to the war file on the server you are deploying it to. This particular method does not ‘push’ a war file to the destination server.
For example: (this should all be on one line, but for formatting reasons, I had to split it up…)
wget
“http://admin:test1234@blojzsp1:8080/manager/deploy?path=/testapp&war=file:/staging/testapp.war”
-O – -q
OK – Deployed application at context path /testapp
Stop
You can stop a particular application:
wget “http://:@:/manager/stop?path=/” -O – -q
For example:
wget “http://admin:test1234@blojzsp1:8080/manager/stop?path=/testapp” -O – -q
OK – Stopped application at context path /testapp
Notice the application shows as ‘stopped’ when you list the applications:
wget http://admin:test1234@blojszp1:8080/manager/list -O – -q
/balancer:running:0:balancer
/testapp:stopped:0:testapp
/host-manager:running:0:/u01/app/tomcat/server/webapps/host-manager
/:running:0:ROOT
/manager:running:0:/u01/app/tomcat/server/webapps/manager
Start
And to start that application:
wget “http://:@:/manager/start?path=/” -O – -q
For example:
wget “http://admin:test1234@blojzsp1:8080/manager/start?path=/testapp” -O – -q
OK – Started application at context path /testapp

Leave a Comment