重新加载 Systemd 配置

systemctl daemon-reload

启动服务

systemctl start test.service

关闭服务

systemctl stop test.service

重启服务

systemctl restart test.service

显示服务的状态

systemctl status test.service

在开机时启用服务

systemctl enable test.service

在开机时禁用服务

systemctl disable test.service

查看服务是否开机启动

systemctl is-enabled test.service

查看已启动的服务列表

systemctl list-unit-files|grep enabled

查看启动失败的服务列表

systemctl --failed

创建tset.service

vi /etc/systemd/system/test.service

写入下列内容

[Unit]
Description = Service description
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
ExecStart = /path/to/bin/file #欲启动的程序

[Install]
WantedBy = multi-user.target