11

Tomcat 7 is running on a Windows System. I need to restart one of the deployed web applications each day at a specific time. Is there an option to do that via script or (even better) does tomcat offer a feature to do so?

Is it possible to use Curl to emulate the click on the reload button on the "list applications" page?

jalu
  • 113
  • 1
  • 1
  • 6
  • Why do you need to restart it? Is restarting the webapp sufficient? If so see https://stackoverflow.com/questions/1800784/whats-an-easy-quick-way-to-reload-a-webapp-in-tomcat-in-dev-environment – rogerdpack Oct 12 '17 at 16:30

1 Answers1

9
curl --user admin:admin http://localhost:8080/manager/text/reload?path=/myapp

Doc here: Manager App HOW-TO, Reload An Existing Application

The manager-script role is required for the user as the documentation says:

It would be quite unsafe to ship Tomcat with default settings that allowed anyone on the Internet to execute the Manager application on your server. Therefore, the Manager application is shipped with the requirement that anyone who attempts to use it must authenticate themselves, using a username and password that have the role manager-script associated with them. Further, there is no username in the default users file ($CATALINA_BASE/conf/tomcat-users.xml) that is assigned this role. Therefore, access to the Manager application is completely disabled by default.

Note: Tomcat 6 uses different management urls. (Apache Tomcat 6.0 Manager App HOW-TO)

palacsint
  • 477
  • 3
  • 9
  • Reload is not recommended in production environment. https://www.mulesoft.com/tcat/tomcat-reload – Xiaokun Aug 05 '20 at 09:40