2017-07-12 25 views
0

我做了一個簡單的systemd服務文件在系統啓動運行命令:Systemd單元手動檔但不能工作在啓動

[Unit] 
Description=Executable Service 
After=multi-user.target 

[Service] 
Type=oneshot 
ExecStart=/path/to/command 

只需要在開機運行一次。然後我啓用它:

systemctl enable executable.service 

systemctl is-enabled executable.service 
enabled 

然後我重新啓動服務器(它運行的CentOS 7.3),它不跑,我只是得到:

systemctl status executable.service 
● executable.service - Executable Service 
    Loaded: loaded (/usr/lib/systemd/system/executable.service; enabled; vendor preset: disabled) 
    Active: inactive (dead) 

一旦我手動啓動該服務:

systemctl start executable.service 

它工作沒有像我所期望的問題。

回答

0

你也必須安裝它到一個目標。即添加以下部分:

[Install] 
WantedBy=default.target 
相關問題