command line
默认配置路径
启动,关闭
sudo systemctl [stop|start|restart] application.service
重新加载service配置
sudo systemctl reload application.service
sudo systemctl daemon-reload # 加载所有
启动编辑
sudo systemctl edit nginx.service
sudo systemctl edit --full nginx.service
模板示例
[Unit]
Description=Application Description
Documentation=http://docs.app.com
After=network.target
[Service]
Type=simple
# command line example
ExecStart=/root/frp-client/frpc -c /root/frp-client/config/frpc.ini
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process
user=root
group=root
[Install]
WantedBy=multi-user.target
- 参考 https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units https://wiki.archlinux.org/title/systemd#Service_types