【发布时间】:2017-02-13 18:36:51
【问题描述】:
我正在尝试编写自己的(简单的)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
一直试图找出过去 2 天出了什么问题。
【问题讨论】:
-
日志文件中是否有任何内容?你确定你可以写信到那个位置吗?
-
你是否让
chmod +x myScript的脚本可执行?祝你好运。 -
@l0b0 是的,有写访问权限。
-
@shellter 我猜脚本有写权限。
标签: linux sh systemd systemctl