树莓派2b使用ubuntu22开启启动自动执行自定义sh文件

之前设置了frp,要跟随系统自动启动,直接vi /etc/rc.local

发现没了,这文件没了。。。搜索网络资料发现是没开启默认的这个rc.local服务

直接转一下别人的流程

复制代码
自动启动

1. 修改/lib/systemd/system/rc-local.service, 在后面追加以下内容:

[Install]
WantedBy=multi-user.target
Alias=rc-local.service
2. 创建/etc/rc.local:

touch /etc/rc.local
3. 添加可执行权限:

chmod +x /etc/rc.local
4. 将rc-local.service服务设置为开机自动启动

systemctl enable rc-local.service
5. 启动rc-local.service服务

systemctl start rc-local.service
6. 检查rc-local.service服务状态,看到绿色的Active: active (running)即代表运行中

systemctl status rc-local.service
7. 创建具体要执行的脚本(挂载坚果云webdav)

mkdir /autoRunShell
cd /autoRunShell
touch mountWebdav.sh
chmod +x mountWebdav.sh
ls
8. 编辑脚本/autoRunShell/mountWebdav.sh的内容:

#!/bin/bash
mount -t davfs https://dav.jianguoyun.com/dav/ /cloud/jianguoyun/
exit 0
9. 在/etc/rc.local中指定开机启动需要执行的脚本:

#!/bin/bash
bash /autoRunShell/mountWebdav.sh
exit 0
10. 重启
------------------------------------------------

                            版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
                        
原文链接:https://blog.csdn.net/qq285744011/article/details/137750762

然后就可以在/etc/rc.local 里面增加自己常用的启动命令了

frp自动启动

相关推荐
jarreyer2 小时前
【AI Agent】大模型自动化载体
运维·自动化
xixingzhe23 小时前
SpringBoot + Nginx 免鉴权接口安全防护方案
运维·nginx·安全
翼龙云_cloud3 小时前
阿里云国际代理商:阿里云 ECS 全维度监控配置教程
运维·阿里云·云计算·监控
笑锝没心没肺4 小时前
fail2ban工具安装配置及使用
linux·运维·服务器
zt1985q5 小时前
本地部署开源智能家居集成平台 ioBroker 并实现外部访问( Windows 版本)
运维·服务器·智能家居
大卡片5 小时前
linux内核驱动开发
linux·运维·驱动开发
心心喵7 小时前
[linux] nohup和pm2的区别 进程保活
linux·运维·服务器
NGINX开源社区8 小时前
F5 NGINX Ingress Controller 5.3.0 新增功能
运维
醉熏的石头8 小时前
Ubuntu 中的编程语言(中)
linux·ubuntu·scala
SelectDB9 小时前
Apache Doris 在 AgentLogsBench 中领先,支撑 Agent 可观测性生产负载
运维·数据库·agent