shell script to kill tomcat service if it is not stopped by stop command after certain amount of time?

后端 未结 2 1330
不知归路
不知归路 2021-01-28 05:15

I would like to write shell script to start and stop tomcat server.For stopping the tomcat I am using this command \"./bin/shudown.sh\" or \"./bin/catalina.sh stop\". This is no

相关标签:
2条回答
  • 2021-01-28 05:40

    ./bin/catalina.sh should support this. If you run that command without any options, it will print out its usage, which describes:

    stop n -force    Stop Catalina, wait up to n seconds and then use kill -KILL if still running
    

    In order to make this work, you need to set the environment variable CATALINA_PID to a file name that will be used to hold the Tomcat process ID. To start Tomcat, use:

    export CATALINA_PID=/tmp/catalina.pid
    ./bin/catalina.sh start
    

    And then to stop it:

    export CATALINA_PID=/tmp/catalina.pid
    ./bin/catalina.sh stop 600 -force
    

    This will try to stop it, wait for 5 minutes, then kill it if necessary. Note that this will run in the foreground by default (locking up the terminal instance); use a trailing & to run the command in the background.

    0 讨论(0)
  • 2021-01-28 05:46

    You can use: pkill -9 tomcatServiceName or killall -9 tomcatServiceName.

    0 讨论(0)
提交回复
热议问题