What is the difference between Apache Tomcat catalina.sh and startup.sh scripts?

Tech Insights

The Apache Tomcat is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. It was started as an open source project by the Apache Software Foundation(ASF) in 1999. From the starting time, Tomcat has proven to be a popular application server for web developers around the globe.

Catalina is the core component of Tomcat. It acts as the servlet container. In simple words, we start Catalina to start the Tomcat application server and deploy web applications. If you check the Tomcat’s bin folder, you will see 2 script (.sh in Linux and .bat in Windows) files named catalina.sh/catalina.bat and startup.sh/startup.bat. You might have used both of these scripts to start your Tomcat server and even wondered why both of them are in place. Let’s see the differences:

catalina.sh is the main control script for Tomcat. It can be executed to start the Tomcat server in different ways:

  1. catalina.sh <run>: this command starts the Tomcat in the foreground and displays the running logs in the same console you are currently in. The process is terminated by closing the window/terminal. Also, hitting Ctrl+C will terminate Tomcat. So unless you are in local or dev environments, need to be careful while using catalina command along with run option.
  2. catalina.sh <start>: starts the Tomcat in the background. You will have to use the tail command to see the logs as following:
tail -f $CATALINA_HOME/logs/catalina.out

To see other options you can use with catalina.sh, run ./catalina.sh -h

startup.sh is the easiest way to start your Tomcat server. If you open the startup.sh file you can see that it’s a small file which in turn calls the catalina.sh start command. So the server is started in the background eventually.

Related read: How to use setenv.sh script to export environment variables in Tomcat?