Linux service and service management in two ways systemctl

Linux service and service management in two ways systemctl

Linux service and service management in two ways systemctl

1.service command
service command actually go /etc/init.d directory, to perform procedures

# service命令启动redis脚本
service redis start
# 直接启动redis脚本
/etc/init.d/redis start
# 开机自启动
update-rc.d redis defaults

Which need to write our own script

2.systemctl command
systemd Linux system is the latest system initialization (init), the role is to improve the startup speed of the system, start the process as less as possible more complicated process started.
systemd corresponding process management command is systemctl

1) systemctl command compatible with the service
that is systemctl will go to /etc/init.d directory, view, execution procedures

systemctl redis start
systemctl redis stop
# 开机自启动
systemctl enable redis

2) management of resources Unit systemctl command systemd
systemd of Unit placed in the directory / usr / lib / systemd / system (Centos) or / etc / systemd / system (Ubuntu )

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

.mount file

.mount file defines a mount point, [Mount] node disposed in the What, Where, Type three data items
equivalent to the following commands:

mount -t hugetlbfs /dev/hugepages hugetlbfs

.service file

.service file defines a service, divided into [Unit], [Service], [Install] three sections
[Unit]
the Description: Description,
the After: in network.target, after auditd.service start start
ConditionPathExists: Executing condition

[Service]
EnvironmentFile: Variable where the file
ExecStart: executing the startup script
Restart: restart when fail

[The Install]
Alias: Alias Service
WangtedBy: multi-user mode needs

.target file

.target defines some basic components, file calls for .service

.wants file

.wants document defines a set of files to be executed, each execution, file folders inside .wants will be executed

Published 12 original articles · won praise 0 · Views 190

Guess you like

Origin blog.csdn.net/u010132847/article/details/103955110