From a2b6019eaeec6d505b9feb65946a78083820600d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Mon, 25 Oct 2021 15:00:01 +0800 Subject: [PATCH] =?UTF-8?q?enhance:=E4=B8=BAsystemctl=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/_posts/about-systemctl.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/source/_posts/about-systemctl.md b/source/_posts/about-systemctl.md index d96ed1c..d6a6e35 100644 --- a/source/_posts/about-systemctl.md +++ b/source/_posts/about-systemctl.md @@ -258,4 +258,24 @@ Install区块是被`systemctl enable`和`systemctl diasble`命令使用确定Uni - `Alias`,定义Unit的别名。Unit的别名可以在其他的Unit定义文件中使用,但是要求一个Unit的别名必须拥有相同的后缀。并且如果一个Unit拥有多个别名,那么在执行`systemctl enable`命令的时候,将会创建多个符号链接。 - `WantedBy`,`RequiredBy`,会在`.wants`和`.requires`命名的Target目录中创建当前Unit的符号链接,使当前Unit可以被指定的Target所包含。 -- `Also`,设置与当前Unit一同被安装和卸载的Unit。 \ No newline at end of file +- `Also`,设置与当前Unit一同被安装和卸载的Unit。 + +## 常见问题 + +### 设置的服务在启动的时候报`Default-Start contains no runlevels` + +这种错误在比较旧的Linux系统中很少出现,反而在比较新的Linux系统中更容易出现。一旦出现了这种错误,服务将不会启动。但其实这种错误也十分容易解决,这种错误一般表示服务的启动脚本中没有定义`Default-Start`所可以使用的`runlevel`。 + +要解决这个错误,只需要在服务的启动脚本开头的位置加入以下代码即可。 + +```bash +### BEGIN INIT INFO +# Provides: service-name +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: +# Description: +### END INIT INFO +```