Apache Tomcat startup / shutdown scripts

How to run Apache Tomcat, startup and shutdown scripts. Customization using catalina script, usage of JAVA_HOME and JAVA_OPTS variables. Setting maximum heap size (Xmx) and maximum perm gen size (XX:MaxPermSize).

In bin directory we have several scripts. If you use Windows, you can safely delete all files ending with sh extension. On the other hand if you use Linux, you can safely delete all files ending with bat extension.

 

In this directory you will mostly use startup and shutdown scripts. Both files use script with name catalina. Inside is some information about used environment variables.

 

Two of them are most important. JAVA_HOME, which must point at your Java Development Kit installation and JAVA_OPTS, where may be parameters used by Java virtual machine. Whole Apache Tomcat is just a Java SE application, so it uses these variables. You can set them inside your operating system, or you can easily set them in catalina file.

 

In JAVA_OPTS it's crutial to set maximum heap size and maximum perm gen size for Tomcat because all web applications running on this server share these memory settings.