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

07-16 1426阅读

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

树莓派2b使用ubuntu22开启启动自动执行自定义sh文件
(图片来源网络,侵删)

发现没了,这文件没了。。。搜索网络资料发现是没开启默认的这个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自动启动

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]