CentOS boot automatically executes shell script to start Tomcat server

Source: Internet
Author: User
Tags tomcat server

Sometimes it is necessary to start the project automatically after the start of the CentOS system, when the project is deployed in Tomcat, if the CentOS shutdown after the boot, the project has been stopped, and then need to be a manual to open each project corresponding Tomcat server, think is more trouble, So how can it be done, and when CentOS starts, the project is automatically followed up?

The following describes how CentOS boot is automatically started shell script, through the shell script command to start the project corresponding Tomcat server.

First, switch to the/ETC/INIT.D directory

Cd/etc/init.d

Second, make SH script: Vim starttomcat.sh

#!/bin/sh#add for chkconfig#chkconfig:2345 #description: The description of the Shellservice iptables stopcd/home/to mcat7/bin./catalina.sh start

Description

2345 refers to the running level of the script, that is, in 2345 of the 4 modes can be run, 234 are text interface, 5 is the graphical interface x

70 refers to the future startup sequence number of the script, if the start sequence number of other programs is smaller than 70 (such as 44, 45), the script needs to wait until these programs are started before starting.

30 refers to the stop order number of the script when the system shuts down.

How the shell script executes multiple commands under Linux:

1. Separate each command;

Note: The execution of each command will not affect the execution of other commands. In other words, each command executes, but does not guarantee that each command will execute successfully.

2. Separate && between each command

Note: If the previous command executes successfully, the following command will be executed. This ensures that after all commands have been executed, the execution process is successful.

3. Between each command with | | Separated

Description: | | It means that only the preceding command fails to execute the next command until a successful command is executed.

Third, add executable permissions to the script:

chmod +x starttomcat.sh

Iv. using the Chkconfig command to set the script to self-start: chkconfig--add starttomcat.sh


Five, restart the machine test: reboot

This article is from the "Simplelife" blog, make sure to keep this source http://simplelife.blog.51cto.com/9954761/1882097

CentOS boot automatically executes shell script to start Tomcat server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.