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

Brief analysis of mysql scheduled backup tasks

Introduction In a production environment, in orde...

Steps to solve the MySQL 8.0 time zone problem

Software Version Windows: Windows 10 MySQL: mysql...

Sample code for partitioning and formatting a disk larger than 20TB on centos6

1. Server environment configuration: 1. Check dis...

Summary of common Nginx techniques and examples

1. Priority of multiple servers For example, if e...

Implementation of Vue top tags browsing history

Table of contents nonsense Functions implemented ...

How to execute PHP scheduled tasks in CentOS7

Preface This article mainly introduces the releva...

The table tbody in HTML can slide up and down and left and right

When the table header is fixed, it needs to be di...

Win10 install Linux ubuntu-18.04 dual system (installation guide)

I installed a Linux Ubuntu system on my computer....

Using JavaScript to implement carousel effects

This article shares the specific code for JavaScr...

Nginx domain name SSL certificate configuration (website http upgraded to https)

Preface HTTP and HTTPS In our daily life, common ...

User needs lead to marketing-oriented design

<br />For each of our topics, the team will ...

Mini Program to Implement the Complete Shopping Cart

The mini program implements a complete shopping c...

How to periodically clean up images that are None through Jenkins

Preface In the process of continuous code deliver...