VM 重新启动后 Systemd 服务未重新启动

VM 重新启动后 Systemd 服务未重新启动

我有一个systemd具有以下单元文件的服务

[Unit]
Description=Custom service 
After=network.target

[Service]
ExecStart=/usr/local/bin/my-script
Restart=always
Environment=FOO=BAR
StandardOutput=append:/var/log/my-service/out.log
StandardError=append:/var/log/my-service/err.log

但是,虚拟机重新启动后,它不会重新启动。

当我尝试启用它时,我得到以下信息

sudo systemctl enable my-service.service
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

我应该为单元文件选择上述哪些选项?

我只想在每次重新启动后启动我的服务。

相关内容