创建服务文件
sudo vim /etc/systemd/system/frpc.service
其中ExecStart请自行替换
以frp为例
/opt/frp/frpc -c /opt/frp/frpc.ini
[Unit]
Description=Frp Client
After=network.target
Wants=network.target
[Service]
Restart=on-failure
RestartSec=5
ExecStart=/opt/frp/frpc -c /opt/frp/frpc.ini
[Install]
WantedBy=multi-user.target
刷新服务列表:
systemctl daemon-reload
设置开机自启
systemctl enable frpc
关闭开机自启
systemctl disable frpc
启动服务
systemctl start frpc
停止服务
systemctl stop frpc
下面是一些常用的systemctl
命令
systemctl disable frpc.service
# 停止服务
systemctl stop frpc.service
# 重启服务
systemctl restart frpc.service
# 查看状态
systemctl status frpc.service
# 查看是否设置开机自启
systemctl is-enabled frpc.service