admin管理员组

文章数量:1794759

Linux Service配置文件的编写

Linux Service配置文件的编写

通过编写Service配置文件,可以使用Linux的 systemctl 命令来达到管理服务的启动、自启动、停止 特定脚本、进程的目的。

编写方法: 文件命名:xxxx.service

[Unit] Description=Frp Server Service #服务的描述信 After=network.target #其中network.target代表有网路,network-online.target代表一个连通着的网络。 [Service] Type=simple User=nobody Restart=1 # 如果这个服务停止了,那么就重启 RestartSec=5s ExecStart=/usr/bin/frps -c /etc/frp/frps.ini #服务的启动命令 [Install] WantedBy=multi-user.target

编写好了以后,把这个文件拷贝到/etc/systemd/system/ 目录,然后执行如下命令:

systemctl enable xxx #开启这个服务的开机自启 systemctl start xxx #启动服务 systemctl stop xxx #停止服务 systemctl status xxx #服务的运行信

本文标签: 配置文件Linuxservice