Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Systemctl状态显示已成功,但服务处于非活动状态_Linux_Bash_Debian_Systemd_Systemctl - Fatal编程技术网

Linux Systemctl状态显示已成功,但服务处于非活动状态

Linux Systemctl状态显示已成功,但服务处于非活动状态,linux,bash,debian,systemd,systemctl,Linux,Bash,Debian,Systemd,Systemctl,我有一个简单的/etc/systemd/system/test.service文件 [Unit] Description=SkriptA After=network.target auditd.service [Service] Type=simple ExecStart=/opt/test.sh [Install] WantedBy=multi-user.target 当我运行systemctl start test.service然后运行systemctl status test.se

我有一个简单的
/etc/systemd/system/test.service
文件

[Unit]
Description=SkriptA
After=network.target auditd.service

[Service]
Type=simple
ExecStart=/opt/test.sh

[Install]
WantedBy=multi-user.target
当我运行
systemctl start test.service
然后运行
systemctl status test.service
时,显示服务成功,但无效,请问这是为什么

● test1.service - SkriptA
   Loaded: loaded (/etc/systemd/system/test1.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 05 12:17:55 hro0078 systemd[1]: Started SkriptA.
Mar 05 12:17:55 hro0078 systemd[1]: test1.service: Succeeded.
ExecStart脚本与服务一样简单

#!/usr/bin/bash

echo Hi > /tmp/test1
date >> /tmp/test1

我使用:
Linux版本4.19.0-13-amd64(debian-kernel@lists.debian.org)(gcc版本8.3.0(Debian 8.3.0-6))#1 SMP Debian 4.19.160-2(2020-11-28)

您的程序已成功启动,并直接终止

要使您的服务
处于活动状态
,它需要保持运行。例如:

#!/usr/bin/bash

while [ 1 ]; do
    echo Hi > /tmp/test1
    date >> /tmp/test1
    sleep 60
done

您的程序已成功启动,并直接终止

要使您的服务
处于活动状态
,它需要保持运行。例如:

#!/usr/bin/bash

while [ 1 ]; do
    echo Hi > /tmp/test1
    date >> /tmp/test1
    sleep 60
done

每个systemctl状态的含义并非特定于编程;systemctl的所有用户和计算机管理员都感兴趣。在Unix和Linux Stackexchange或超级用户上尝试。每个systemctl状态的含义并不是特定于编程的;systemctl的所有用户和计算机管理员都感兴趣。在Unix和Linux Stackexchange或超级用户上尝试。