Systemd

啟用的 systemd 服務不會在啟動時啟動

  • November 16, 2020

我啟用了 7 個服務,其中 6 個依賴於第一個啟動的 1 個,並且執行良好。3 啟動正常,其他 3 啟動時不會啟動,但如果我執行sudo systemctl start service它執行正常。

你能幫忙嗎?

守護程序

[Unit]
Description=SABnzbd Client
After=network.target openvpn@client.service

[Service]
Type=simple
User=tatsu
Group=tatsu
ExecStart=/usr/bin/python3 -OO /opt/SABnzbd/SABnzbd.py --browser 0 -s 192.168.0.227:8080
Restart=always

[Install]
WantedBy=multi-default.target

地位

● sabnzbd.service - SABnzbd Client
  Loaded: loaded (/etc/systemd/system/sabnzbd.service; enabled; vendor preset: enabled)
  Active: inactive (dead)

執行sudo systemctl start sabnzbd後的狀態

● sabnzbd.service - SABnzbd Client
  Loaded: loaded (/etc/systemd/system/sabnzbd.service; enabled; vendor preset: enabled)
  Active: active (running) since Mon 2020-11-16 09:07:50 GMT; 9s ago
Main PID: 749 (python3)
   Tasks: 22 (limit: 1147)
  Memory: 61.6M
  CGroup: /system.slice/sabnzbd.service
          └─749 /usr/bin/python3 -OO /opt/SABnzbd/SABnzbd.py --browser 0 -s 192.168.0.227:8080

Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,686::INFO::[SABnzbd:1427] Starting web-interface on 192.168.0.227:
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,687::INFO::[_cplogging:216] [16/Nov/2020:09:07:54] ENGINE Bus STAR
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,794::INFO::[_cplogging:216] [16/Nov/2020:09:07:54] ENGINE Serving 
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,795::INFO::[_cplogging:216] [16/Nov/2020:09:07:54] ENGINE Bus STAR
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,796::INFO::[SABnzbd:1464] Starting SABnzbd.py-3.1.1
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,807::INFO::[dirscanner:117] Dirscanner starting up
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,813::INFO::[urlgrabber:96] URLGrabber starting up
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,813::INFO::[notifier:122] Sending notification: SABnzbd - SABnzbd 
Nov 16 09:07:54 tatsu-dl python3[749]: 2020-11-16 09:07:54,836::INFO::[postproc:232] Completed Download Folder /downloads/com
Nov 16 09:07:55 tatsu-dl python3[749]: 2020-11-16 09:07:55,269::INFO::[zconfig:71] No Bonjour/ZeroConfig support installed

其他 3 個對於它們各自的應用程序都是相同的

問題出在您的安裝部分:

[Install]
WantedBy=multi-default.target

multi-default.target不是一回事。 systemd.special(7)列出了您可以依賴的目標。default.target如果這是--user匯流排的一部分,或者multi-user.target如果這是系統匯流排的一部分,您應該使用。看起來您正在使用系統匯流排。

首先使用systemctl disable <service>刪除符號連結multi-default.target,然後將安裝部分更改為:

[Install]
WantedBy=multi-user.target

然後systemctl daemon-reload載入更改並systemctl enable <service>再次使用。

引用自:https://unix.stackexchange.com/questions/619858