CLI Tomcat Server Control with Wget and the Tomcat Manager
Tags:
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://<username>:<password>@<hostname>:<port>/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://<username>:<password>@<hostname>:<port>/manager/undeploy?path=/<context 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://<user>:<pass>@<host>:<port>/manager/deploy?path=/<context>&war=file:<filepath>" -O - -q
Where the "war=file:
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://<username>:<password>@<hostname>:<port>/manager/stop?path=/<context 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://<username>:<password>@<hostname>:<port>/manager/start?path=/<context path>" -O - -q
For example:
wget "http://admin:test1234@blojzsp1:8080/manager/start?path=/testapp" -O - -q OK - Started application at context path /testapp
- Add new comment
- 5191 reads

Thanks, I've been looking for exactly this!
thanks