Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of service and systemctl in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about sample analysis of service and systemctl in Linux. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

1. The service command

The service command actually goes to the/etc/init.d directory to execute the relevant programs.

# service command start redis script service redis start#start redis script directly/etc/init.d/redis start#boot self-start update-rc.d redis defaults

where we write scripts ourselves.

The systemctl command

systemd is the latest initialization system (init) for Linux systems, which is used to speed up system startup, start as few processes as possible, and start as many processes concurrently as possible.

The process management command for systemd is systemctl.

1)systemctl command is compatible with service

That is, systemctl will also go to/etc/init.d directory, check and execute relevant programs.

systemctl redis startsystemctl redis stop#boot self-start systemctl enable redis

2)systemctl command manages systemd resource units

systemd Units are located in/usr/lib/systemd/system(Centos) or/etc/systemd/system(Ubuntu)

There are four main types of files.mount,.service,.target,.wants

.mount file

The.mount file defines a mount point, and the [Mount] node is configured with three data items: What,Where, and Type.

Equivalent to the following command:

mount -t hugetlbfs /dev/hugepages hugetlbfs

.service file

The.service file defines a service, which is divided into three sections: [Unit],[Service] and [Install].

[Unit]

Description: Description,

After: starts after network.target,auditd.service starts

ConditionPathExists: Execution conditions

[Service]

EnvironmentFile: The file in which the variable is located

ExecuStart: Executes the startup script

Restart: restart when fail

[Install]

Alias: service aliases

WangtedBy: required in multi-user mode

.target file

.target defines some basic components that can be invoked by.service files

.wants files

The.wants file defines a collection of files to execute. Each time it is executed, the files in the.wants folder are executed.

Thank you for reading! About "Linux service and systemctl sample analysis" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report