Two ways to start Linux boot service

Two ways to start Linux boot service

rc.local method

1 First create a script to start automatically

vi /etc/scripts/createFile.sh
#!/bin/bash
#Start up and create a folder mkdir /opt/ccc                   

2. Grant execution permissions

chmod 777 createFile.sh

3. Add the absolute path of the script in the /etc/rc.d/rc.local file

insert image description here

4. Give rc.local execution permissions

chmod 777 rc.local

insert image description here

Restart the service and find that a ccc folder has been created under the opt path

insert image description here

View the script progress

ps -ef | grep createFile

insert image description here

chkconfig method

1. Create a startup script

vi createjava.sh
#!/bin/bash
#chkconfig: 2345 88 99
#description:auto_run

#Start up and create a java file touch /opt/nihao.java
#!/bin/sh
This means that this script uses /bin/sh to interpret and execute #chkconfig: 2345 88 99
2345 means that this service is started when the system operation level is 2, 3, 4 or 5. 88: is the startup priority.
99: is the shutdown priority. Note: If the startup priority is configured too small, such as 0, the startup may fail because the network service it depends on may not be started at this time, resulting in a self-start failure.
 
#description:createjava.sh
Is the description information

2. Grant executable permissions

chmod u+x createjava.sh

3. Copy the script to the /etc/init.d directory

cp createjava.sh /etc/init.d/

4. Add to service

chkconfig --add /etc/init.d/createjava.sh

5. Restart the server

init 6 

The nihao.java file has been created

insert image description here

This concludes the article about two ways to enable Linux startup services. For more information about Linux startup services, please search previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Three ways to set up Linux services to start automatically
  • How to set up Linux service auto-start

<<:  This article teaches you how to play with CSS combination selectors

>>:  How to implement input checkbox to expand the click range

Recommend

Do you know what are the ways to jump routes in Vue?

Table of contents The first method: router-link (...

Detailed explanation of the concept of docker container layers

Table of contents 01 Container consistency 02 Con...

Web design skills: iframe adaptive height problem

Maybe some people have not come across this issue ...

Docker solves the problem that the terminal cannot input Chinese

Preface: One day, I built a MySQL service in Dock...

A record of pitfalls in JS regular matching

I recently discovered a pitfall in regular expres...

Introduction to who command examples in Linux

About who Displays users logged into the system. ...

Detailed explanation of Zabbix installation and deployment practices

Preface Zabbix is ​​one of the most mainstream op...

Writing a rock-paper-scissors game in JavaScript

This article shares the specific code for writing...

Linux directory switching implementation code example

Switching files is a common operation in Linux. W...

Working principle and example analysis of Linux NFS mechanism

What is NFS? network file system A method or mech...

Navicat remote connection to MySQL implementation steps analysis

Preface I believe that everyone has been developi...

Mysql modify stored procedure related permissions issue

When using MySQL database, you often encounter su...

MySQL 8 new features: Invisible Indexes

background Indexes are a double-edged sword. Whil...

MySQL Database Basics SQL Window Function Example Analysis Tutorial

Table of contents Introduction Introduction Aggre...