Linux开机自启相关
方式一:Linux开机自启动脚本
树莓派OPENFANS(Debian-Pi-Aarch64) :
系统支持自定义任务自启动脚本,可以在系统启动前预先配置。
编辑脚本文件 /boot/rc-local
,在 “exit 0” 前加入自定义的脚本内容。
例:
1 |
|
方式二:Systemd开机启动
进入到对应的Systemd目录下新建配置文件:
CentOS 7 中存放Systemd 配置文件路径:/usr/lib/systemd/system
树莓派OPENFANS(Debian-Pi-Aarch64) 中存放Systemd 配置文件路径:/lib/systemd/system
例1:
1 | [Unit] |
例2:
1 | [Unit] |
常用的配置操作命令:
启动服务:systemctl start frp.service
停止服务:systemctl stop frp.service
重启服务:systemctl restart frp.service
查看服务状态:systemctl status frp.service
重新加载配置:systemctl reload frp.service
重新加载所有配置:systemctl daemon-reload
列出所有配置文件:systemctl list-unit-files
列出指定类型的配置文件:systemctl list-unit-files --type=service
开启开机自启:systemctl enable frp.service
关闭开机自启:systemctl disable frp.service
一共有四种状态类型:
- enabled:已建立启动链接
- disabled:没建立启动链接
- static:该配置文件没有 [Install] 部分(无法执行),只能作为其他配置文件的依赖
- masked:该配置文件被禁止建立启动链接
相关资料查阅:
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 imxt!