共计 524 个字符,预计需要花费 2 分钟才能阅读完成。
Centos7/Centos8 要 chmod +x /etc/rc.d/rc.local 授权一下才会起作用
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
当然有的时候也可能不成功,比如:
/etc/rc.d/rc.local 文件中的内容格式不正确:
开头少了 #!/bin/bash,也是执行不成功的,会提示你格式不对。
此外还可能是没有启动此项服务:
[root@localhost ~]# systemctl list-units --type=service #来查看一下所有的开启启动项目里面有没有这个 rc-local 这个服务。[root@localhost ~]# systemctl status rc-local.service #来查看一下当前是怎么个状态
然后:
[root@localhost ~]# systemctl enable rc-local.service
[root@localhost ~]# systemctl start rc-local.service
# 手工添加下开机启动或者手工起一下看报错信息。
另外:服务的启动文件是存放在了:/lib/systemd/system/ 目录下面,如果不记得这个服务的全称可以来这个目录下面看。
微信打赏
支付宝打赏
正文完