Linux开机启动rc.local不生效的一般解决方案

问题描述:在rc.local 添加了执行脚本,但是系统启动后,脚本没有执行。

 

1. 给rc.local 添加可执行权限

sudo chmod +x /etc/rc.d/rc.local

 

2. rc-local.service增加 install 节点配置

sudo vi /usr/lib/systemd/system/rc-local.service

在文件中添加以下内容

[Install]
WantedBy=multi-user.target

 

3. 启动rc-local服务

systemctl start rc-local

 

4. 设置rc-local服务开机自启动

systemctl enable rc-local

 

5. 查看rc-local服务状态

systemctl status rc-local

 

posted @ 2022-04-27 10:10  JeremyYu  阅读(4470)  评论(0编辑  收藏  举报