更新README.md文件

This commit is contained in:
huty 2024-05-10 15:49:00 +00:00 committed by cloud-init created default user
parent c02391ca11
commit 079d7fe4ff

View File

@ -1,3 +1,99 @@
# systemd_service # systemd_service
Systemd 的 service 文件示例 Systemd 的 service 文件示例
<br/>
## 文件说明
### 仓库文件
#### 说明文件
``` bash
description/description.service
```
#### 示例文件
- docker
``` bash
examples/docker.service
```
- redis
``` bash
examples/redis.service
```
- tomcat
``` bash
examples/tomcat.service
```
### 安装目录
``` bash
/usr/lib/systemd/system/
```
``` bash
/etc/systemd/system/
```
> 其中 /etc/systemd/system/ 目录中的 service 文件在开机时自执行
<br/>
## 命令示例
- 重载配置文件
``` bash
systemctl daemon-reload
```
- 查看服务状态
``` bash
systemctl status [service 文件名称]
```
示例:
``` bash
systemctl status docker.service
```
- 启动服务
``` bash
systemctl start [service 文件名称]
```
示例:
``` bash
systemctl start docker.service
```
- 停止服务
``` bash
systemctl stop [service 文件名称]
```
示例:
``` bash
systemctl stop docker.service
```
- 重启服务
``` bash
systemctl restart [service 文件名称]
```
示例:
``` bash
systemctl restart docker.service
```
- 开启开机自启动
``` bash
systemctl enable [service 文件名称]
```
示例:
``` bash
systemctl enable docker.service
```
- 取消开机自启动
``` bash
systemctl disable [service 文件名称]
```
示例:
``` bash
systemctl disable docker.service
```