linux – systemctl status显示inactive dead
发布时间:2020-12-14 02:22:23 所属栏目:Linux 来源:网络整理
导读:我正在尝试编写自己的(简单的)systemd服务,它可以做一些简单的事情.(就像使用 shell脚本将数字1到10写入文件一样). 我的服务文件如下所示. [Unit]Description=NandaGopalDocumentation=https://google.comAfter=multi-user.target[Service]Type=forking Rema
我正在尝试编写自己的(简单的)systemd服务,它可以做一些简单的事情.(就像使用
shell脚本将数字1到10写入文件一样).
我的服务文件如下所示. [Unit] Description=NandaGopal Documentation=https://google.com After=multi-user.target [Service] Type=forking RemainAfterExit=yes ExecStart=/usr/bin/hello.sh & [Install] RequiredBy = multi-user.target 这是我的shell脚本. #!/usr/bin/env bash source /etc/profile a=0 while [ $a -lt 10 ] do echo $a >> /var/log//t.txt a=`expr $a + 1` done 由于某种原因,服务没有出现,systemctl显示以下输出. root@TARGET:~ >systemctl status -l hello * hello.service - NandaGopal Loaded: loaded (/usr/lib/systemd/system/hello.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: https://google.com 一直想弄清楚过去两天出了什么问题. 问候, 解决方法
>您已设置Type = Forking,但您的服务不起作用.尝试
TYPE =单稳 >你有一个“&”您的ExecStart行,这是不必要的. >该服务已禁用,这意味着它无法在启动时启动.您应该运行systemctl enable hello将其设置为在启动时启动. 您可以检查man systemd.directives以查找可在单元文件中使用的所有指令的索引. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |