root@ubuntu:/# systemctl status Openvmi-Xvfb-Manger.service * Openvmi-Xvfb-Manger.service - Openvmi Xvfb Manger Loaded: loaded (/lib/systemd/system/Openvmi-Xvfb-Manger.service; enabled; ven dor preset: enabled) Active: inactive (dead)
root@ubuntu:/# find ./ -name Openvmi-Xvfb-Manger.service ./lib/systemd/system/Openvmi-Xvfb-Manger.service ./etc/systemd/system/multi-user.target.wants/Openvmi-Xvfb-Manger.service
优先级 systemd的使用大幅提高了系统服务的运行效率, 而unit的文件位置一般主要有三个目录: Table 1. Load path when running in system mode (--system). ┌────────────────────────┬─────────────────────────────┐ │Path │ Description │ ├────────────────────────┼─────────────────────────────┤ │/etc/systemd/system │ Local configuration │ ├────────────────────────┼─────────────────────────────┤ │/run/systemd/system │ Runtime units │ ├────────────────────────┼─────────────────────────────┤ │/lib/systemd/system │ Units of installed packages │ └────────────────────────┴─────────────────────────────┘ 这三个目录的配置文件优先级依次从高到低,如果同一选项三个地方都配置了,优先级高的会覆盖优先级低的
systemctl list-unit-files -t service
PS:使用命令 systemctl is-enabled postfix.service 得到的值可以是enable、disable或static,这里的 static 它是指对应的 Unit 文件中没有定义[Install]区域,因此无法配置为开机启动服务。
a template for multiple Xvfb services Simple xvfb.service systemd unit files for xvfb can be found at https://www.centos.org/forums/viewtopic.php?f=48&t=49080#p208363 and at https://askubuntu.com/a/621256/43344 . However, as I mentioned at the latter one can also take a templatized approach: [Unit] Description=virtual frame buffer X server for display %I After=network.target [Service] ExecStart=/usr/bin/Xvfb %I -screen 0 1280x1024x24 [Install] WantedBy=multi-user.target As a locally-written, non-system non-packaged, unit file for system-wide (as opposed to per-user) services this goes into /etc/systemd/system/xvfb@.service of course. controlling the services One instantiates the template, into an actual named service, with the display number that is desired. For display :99, therefore, there is an actual service instance named xvfb@:99.service. Set the service to auto-start on bootstrap with systemctl enable xvfb@:99.service . Unset auto-starting the service with systemctl disable xvfb@:99.service . Start the service manually with systemctl start xvfb@:99.service . Stop the service manually with systemctl stop xvfb@:99.service . Inspect the current service status in detail with systemctl status xvfb@:99.service .
原文:https://www.cnblogs.com/dream397/p/14063455.html