服务路径
/lib/systemd/system
或者
/usr/lib/systemd/system/
创建服务
在 /lib/systemd/system
路径下新建 testservice.service
文件内容如下
nano /lib/systemd/system/testservice.service
[Unit]
Description=Clash Service
After=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/root/app/clash/clash -d /root/app/clash/
[Install]
WantedBy=multi-user.target
常用命令
#重新加载服务列表
systemctl daemon-reload
#设为开机启动
systemctl enable testservice.service
#启动服务
systemctl start testservice.service
#重启服务
systemctl restart testservice.service
查看服务日志
# --no-pager
journalctl -u service-name.service --no-pager