Install Tomcat on Linux system and configure Service startup and shutdown

Install Tomcat on Linux system and configure Service startup and shutdown

Configure service startup and shutdown in Linux system

1. Run the command cd /etc/init.d to go to the folder

2. Enter the vim editing interface through the command vim tomcat

3. Use the i key to paste the following code into the editing interface

The shell script is as follows

    #!/bin/bash 
    # This is the init script for starting up the 
    # Jakarta Tomcat server 
    # 
    # chkconfig: 345 91 10 
    # description: Starts and stops the Tomcat daemon. 
    # 
 
    # Source function library. 
    . /etc/rc.d/init.d/functions 
 
    # Get config. 
    . /etc/sysconfig/network 
 
    # Check that networking is up. 
    [ "${NETWORKING}" = "no" ] && exit 0 
 
    export JAVA_HOME=/usr/local/javaweb/jdk1.8.0_192 #your own jdk installation directory tomcat_home=/usr/local/tomcat/tomcat #your own tomcat installation directory startup=$tomcat_home/bin/startup.sh 
    shutdown=$tomcat_home/bin/shutdown.sh 
 
    start(){ 
      echo -n "Starting Tomcat service:" 
      cd $tomcat_home 
      $startup 
      echo "tomcat is successfully started up" 
    } 
 
    stop(){ 
      echo -n "Shutting down tomcat: " 
      cd $tomcat_home 
      $shutdown 
      echo "tomcat is successfully shut down." 
    } 
 
    status(){ 
      numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l` 
      if [ $numproc -gt 0 ]; then 
        echo "Tomcat is running..." 
      else 
        echo "Tomcat is stopped..." 
      fi 
    } 
 
    restart(){ 
      stop 
      start 
    }  
    # See how we were called. 
    case "$1" in 
    start) 
      start 
      ;; 
    stop) 
      stop 
      ;; 
    status) 
      status 
      ;; 
    restart) 
      restart 
      ;; 
    *) 
      echo $"Usage: $0 {start|stop|status|restart}" 
      exit 1 
    esac

(The file cannot be executed, please execute this command) Add permissions to the file so that the script file can be executed. The command is: chmod 755 /etc/rc.d/init.d/tomcat

4. Add the file to the service queue

chkconfig --add tomcat

5. Check whether the tomcat file is successfully added to the service list

chkconfig --list

6. Set the service to start automatically at boot

chkconfig tomcat on

Summary ends here

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Solve the problem that Spring boot embedded tomcat does not start
  • Tomcat starts and completes the execution of a method timing task (Spring) operation
  • How to start source code debugging of tomcat in Idea and enter into tomcat for debugging
  • Idea configures tomcat to start a web project graphic tutorial
  • Quickly solve the problem of slow Tomcat startup, super simple

<<:  Detailed explanation of the difference between routing hooks in Vue2.x and Vue3.x

>>:  MySql index improves query speed common methods code examples

Recommend

React tsx generates random verification code

React tsx generates a random verification code fo...

mysql5.7 create user authorization delete user revoke authorization

1. Create a user: Order: CREATE USER 'usernam...

Use of Linux xargs command

1. Function: xargs can convert the data separated...

Four ways to compare JavaScript objects

Table of contents Preface Reference Comparison Ma...

Detailed example of MySQL (5.6 and below) parsing JSON

MySQL (5.6 and below) parses json #json parsing f...

In-depth explanation of MySQL stored procedures (in, out, inout)

1. Introduction It has been supported since versi...

Detailed explanation of when javascript scripts will be executed

JavaScript scripts can be embedded anywhere in HT...

Practice of deploying web applications written in Python with Docker

Table of contents 1. Install Docker 2. Write code...

JavaScript setinterval delay one second solution

When using setinterval, it is found that it will ...

How to quickly build an LNMP environment with Docker (latest)

Preface Tip: Here you can add the approximate con...

Getting Started with Vue 3.0 Custom Directives

Table of contents 1. Custom instructions 1. Regis...

mysql8.0.11 winx64 manual installation and configuration tutorial

First of all, let me talk to you about my daily l...