Centos7.3 automatically starts or executes specified commands when booting

Centos7.3 automatically starts or executes specified commands when booting

In centos7, the permissions of the /etc/rc.d/rc.local file have been reduced and there is no execution permission. You need to add executable permissions to it.

chmod +x /etc/rc.d/rc.local

Then you can add the command you want to start automatically.

vi /etc/rc.d/rc.local

Additional knowledge: centOS7.2 sets the custom script as a service and starts it at boot

When the spring boot jar package is deployed online, it is hoped that it can be set as a service and started at boot. The steps are as follows:

1. Prepare the script (there are many on the Internet, so I won’t write it here)

2. Create a soft link to the /etc/rc.d/init.d directory

ln -s /springboot/biz /etc/rc.d/init.d

Source file (absolute path) Target path (absolute path)

3. Add execution permissions:

chmod +x biz

4. When executing service abc start, if an error is reported:

line 4: exec: java: not found

Then check the script and add the full path of java as follows:

exec /usr/java/jdk1.8.0_20/jre/bin/java -Xms128m -Xmx1024m -jar

5. Execute service biz start again and it starts successfully

6. Set the startup and modify the script. Add the following to the second line:

# chkconfig: 2345 99 99

7. Add startup:

chkconfig --add biz

chkconfig biz on

The above article about how to automatically start or execute specified commands on Centos7.3 at startup is all I want to share with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Automatically load kernel module overlayfs operation at CentOS startup
  • Three methods to modify the hostname of Centos7
  • Detailed explanation of the basic use of centos7 firewall in linux

<<:  Native JS implements a very good-looking counter

>>:  Summary of commonly used SQL statements for creating MySQL tables

Recommend

JavaScript implements the detailed process of stack structure

Table of contents 1. Understanding the stack stru...

Detailed explanation of identifying files with the same content on Linux

Preface Sometimes file copies amount to a huge wa...

A brief discussion on the role and working principle of key in Vue3

What is the function of this key attribute? Let’s...

Summary of commonly used tool functions in Vue projects

Table of contents Preface 1. Custom focus command...

Share 12 commonly used Loaders in Webpack (Summary)

Table of contents Preface style-loader css-loader...

Detailed explanation of CSS margin collapsing

Previous This is a classic old question. Since a ...

Detailed explanation of js's event loop event queue in the browser

Table of contents Preface Understanding a stack a...

Put frameset in body through iframe

Because frameset and body are on the same level, y...

Vue application example code based on axios request encapsulation

Table of contents What is axios? Axios request ty...

Solution to win10 without Hyper-V

Are you still looking for a way to enable Hyper-v...

How to configure Nginx's anti-hotlinking

Experimental environment • A minimally installed ...

How to use time as a judgment condition in MySQL

Background: During the development process, we of...

Detailed explanation of COLLATION examples in MySQL that you may have overlooked

Preface The string types of MySQL database are CH...

Complete steps to install mysql5.7 on Mac (with pictures and text)

I recently used a Mac system and was preparing to...