From 079d7fe4ff91446ced98d66040a130514fdf723b Mon Sep 17 00:00:00 2001 From: huty Date: Fri, 10 May 2024 15:49:00 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0README.md=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c287a85..e81d5f3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,99 @@ # systemd_service +Systemd 的 service 文件示例 -Systemd 的 service 文件示例 \ No newline at end of file +
+ +## 文件说明 +### 仓库文件 +#### 说明文件 +``` 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 文件在开机时自执行 + +
+ +## 命令示例 +- 重载配置文件 +``` 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 +```