Skip to content

Tomcat Command and Operation Manual

Viewing Tomcat Version Information

Use the version.sh (Linux/Mac) or version.bat (Windows) script to view the Tomcat version information.

# Linux/Mac
./version.sh

# Windows
version.bat

Starting Tomcat

Use the startup.sh (Linux/Mac) or startup.bat (Windows) script to start the Tomcat server.

# Linux/Mac
./startup.sh

# Windows
startup.bat

Stopping Tomcat

Use the shutdown.sh (Linux/Mac) or shutdown.bat (Windows) script to stop the Tomcat server.

# Linux/Mac
./shutdown.sh

# Windows
shutdown.bat

Restarting Tomcat

Stop and then start the Tomcat service.

# Stop Tomcat
./shutdown.sh

# Wait for a few seconds before starting Tomcat
sleep 5
./startup.sh

Setting Environment Variables

You can set the CATALINA_HOME and JAVA_HOME environment variables to specify the installation paths for Tomcat and Java.

# Set CATALINA_HOME
export CATALINA_HOME=/path/to/tomcat

# Set JAVA_HOME
export JAVA_HOME=/path/to/java

Deploying Applications

Copy the WAR file to the webapps/ directory, and Tomcat will automatically deploy the application.

# Copy WAR to webapps
cp myapp.war webapps/

Configuration Files

The main configuration files are located in the conf/ directory, including server.xml, web.xml, and context.xml.

# View server.xml
cat conf/server.xml

# View web.xml
cat conf/web.xml

Log Files

Log files are usually located in the logs/ directory, such as catalina.out and localhost.log.

# View catalina.out
tail -f logs/catalina.out

# View localhost.log
tail -f logs/localhost.log

Debug Mode

Start Tomcat in debug mode for development and troubleshooting.

# Start debugging mode
./catalina.sh jpda start

Cleaning Work Directory

Cleaning the work/ directory can free up disk space and resolve some temporary file issues.

# Cleaning work directory
rm -rf work/Catalina/*