# systemd_service
Systemd 的 service 文件示例
## 文件说明
### 仓库文件
#### 说明文件
``` bash
description/description.service
```
#### 示例文件
- docker
``` bash
examples/docker.service
```
- redis
``` bash
examples/redis.service
```
- tomcat
``` bash
examples/tomcat.service
```
- nginx
``` bash
examples/nginx.service
```
### 安装目录
``` bash
/usr/lib/systemd/system/
```
或
``` bash
/etc/systemd/system/
```
> 其中 /etc/systemd/system/ 目录中的 service 文件在开机时自执行
## 命令示例
- 重载配置文件
``` 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
```