Linux XXXXXXXX 3.10.0-1160.62.1.el7.x86_64 #1 SMP Wed Mar 23 09:04:02 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
cat -vetn rc.service
1 [Unit]$
2 Description=Script Daemon$
3 $
4 [Service]$
5 Type=simple$
6 ExecStart=/opt/xxx/bin/rc$
7 Restart=on-failure$
8 $
9 [Install]$
10 WantedBy=default.target$
作为用户 xxx,当我运行nohup /opt/xxx/bin/rc &
它时运行良好 作为用户 xxx,当/opt/xxx/bin/rc
它运行良好时。
我以 root 身份执行此操作:
systemctl daemon-reload; systemctl enable rc.service;
(No errors thrown)
systemctl status rc.service;
Loaded: loaded (/etc/systemd/system/rc.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Mar 19 14:31:16 XXXXXXXX systemd[1]: [/etc/systemd/system/rc.service:13] Missing '='.
您会注意到我的单元文件只有 10 行!!