Linux systemctl
适用于Linux Ubuntu/Debian
📥️安装 systemd
# 使用 yum 安装 systemd(CentOS/RHEL)
yum install systemd -y
# 使用 apt 安装 systemd(Debian/Ubuntu)
apt install systemd -y
📌以FRP
为例
⚒️创建 🔗frp.service
文件
vim /etc/systemd/system/frp.service
写入内容
🔗frps
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
Requires=network-online.target
[Service]
Type = simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
ExecReload=/opt/frp/frps reload -c /opt/frp/frps.toml
[Install]
WantedBy = multi-user.target
🛠️使用 systemd 命令管理 frp 服务
# 启动frp
systemctl start frp
# 停止frp
systemctl stop frp
# 重启frp
systemctl restart frp
# 查看frp状态
systemctl status frp
⚔️设置 frp 开机自启动
systemctl enable frp