开发者

how to start stop tomcat server using CMD?

开发者 https://www.devze.com 2023-01-31 09:37 出处:网络
I set the path for the tomcat and set all variables like JAVA_HOME=C:\\Program Fil开发者_运维知识库es (x86)\\Java\\jdk1.6.0_22

I set the path for the tomcat and set all variables like

  1. JAVA_HOME=C:\Program Fil开发者_运维知识库es (x86)\Java\jdk1.6.0_22
  2. CATALINA_HOME=G:\springwork\server\apache-tomcat-6.0.29
  3. CLASSPATH=G:\springwork\server\apache-tomcat-6.0.29\lib\servlet-api.jar;G:\springwork\server\apache-tomcat-6.0.29\lib\jsp-api.jar;.;

When I go to bin folder and double click on startup.bat then my tomcat starts and when I double click on shutdown.bat tomcat stops.

But I want using CMD start and stop the tomcat. And in any folder I write command startup.bat the server will start and when I write shutdown.bat the server will stop.


Add %CATALINA_HOME%/bin to path system variable.

Go to Environment Variables screen under System Variables there will be a Path variable edit the variable and add ;%CATALINA_HOME%\bin to the variable then click OK to save the changes. Close all opened command prompts then open a new command prompt and try to use the command startup.bat.


Steps to start Apache Tomcat using cmd:
1. Firstly check that the JRE_HOME or JAVA_HOME is a variable available in environment variables.(If it is not create a new variable JRE_HOME or JAVA_HOME)
2. Goto cmd and change your working directory to bin path where apache is installed (or extracted).
3. Type Command -> catalina.bat start to start the server.
4. Type Command -> catalina.bat stop to stop the server.


This is what I used to start and stop tomcat 7.0.29, using ant 1.8.2. Works fine for me, but leaves the control in the started server window. I have not tried it yet, but I think if I change the "/K" in the startup sequence to "/C", it may not even do that.

<target name="tomcat-stop">
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/C start cmd.exe /C shutdown.bat"/>
    </exec>
</target>



<target name="tomcat-start" depends="tomcat-stop" >
    <exec dir="${appserver.home}/bin" executable="cmd">
        <arg line="/K start cmd.exe /C startup.bat"/>
    </exec>

</target>


you can use this trick to run tomcat using cmd and directly by tomcat bin folder.

1. set the path of jdk.

2.

To set path. go to Desktop and right click on computer icon. Click the Properties

go to Advance System Settings.

then Click Advance to Environment variables.

Click new and set path AS,

in the column Variable name=JAVA_HOME

Variable Value=C:\Program Files\Java\jdk1.6.0_19

Click ok ok.

now path is stetted.

3.

Go to tomcat folder where you installed the tomcat. go to bin folder. there are two window batch files.

1.Startup

2.Shutdown.

By using cmd if you installed the tomcate in D Drive

type on cmd screen

  1. D:

  2. Cd tomcat\bin then type Startup.

4. By clicking them you can start and stop the tomcat.

5.

Final step.

if you start and want to check it.

open a Browser in URL bar type.

**HTTP://localhost:8080/**


Change directory to tomcat/bin directory in cmd prompt

cd C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin

Run the below command to start:

On Linux: >startup.sh

On Windows: >startup.bat

Run these commands to stop

On Linux: shutdown.sh

On Windows: shutdown.bat


Create a .bat file and write two commands:

cd C:\ Path to your tomcat directory \ bin

startup.bat

Now on double-click, Tomcat server will start.


I have just downloaded Tomcat and want to stop it (Windows).

  1. To stop tomcat

    • run cmd as administrator (I used Cmder)

    • find process ID

tasklist /fi "Imagename eq tomcat*"

C:\Users\Admin
tasklist /fi "Imagename eq tomcat*"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
Tomcat8aaw.exe                6376 Console                    1      7,300 K
Tomcat8aa.exe                 5352 Services                   0    124,748 K
  • stop prosess with pid 6376

C:\Users\Admin

taskkill /f /pid 6376

SUCCESS: The process with PID 6376 has been terminated.

  • stop process with pid 5352

C:\Users\Admin

taskkill /f /pid 5352

SUCCESS: The process with PID 5352 has been terminated.


There are multiple ways to Start and Stop Apache Tomcat Server in Linux and Windows Operating systems. Below is detail facts. Locate the bin folder in your tomcat server and execute the following commands in CMD/ Terminal.

Linux:

./catalina.sh run

Passing "run" argument for catalina.sh --> starts the Tomcat in the foreground and displays the running logs in the same console. when the console terminal is closed it will terminate the tomcat.

./catalina.sh start | ./catalina.sh stop

Passing "start" argument for catalina.sh --> starts the Tomcat in the background. Since in background no issues closing down the terminal. The logs need to be viewed as below: tail -f $CATALINA_HOME/logs/catalina.out

./startup.sh | ./shutdown.sh 

The last way is firing the startup.sh to start your Tomcat server. If you Vi the script you can see it calls catalina.sh script passing start as the argument. This will be running in background as well.

Windows:

startup.bat // start tomcat server
shutdown.bat // stop tomcat server


You can use the following command c:\path of you tomcat directory\bin>catalina run

0

精彩评论

暂无评论...
验证码 换一张
取 消