工作中发现Centos 7的系统在rc.local添加开机启动命令,但重启后发现无效,试了多次还是一样
检查系统rc.local服务运行情况
systemctl | grep "rc.local"
rc-local.service loaded active exited /etc/rc.d/rc.local Compatibility
发现运行正常
随后查看rc.local文件
cat /etc/rc.local
发现这么一句话
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 [2017-12-07 11:50] /etc/rc.local -> rc.d/rc.local
由于/etc/rc.local是/etc/rc.d/rc.local的软连接,所以必须确保/etc/rc.local和/etc/rc.d/rc.local都有x权限(可执行)
执行命令
chmod +x /etc/rc.d/rc.local
重启,一切正常,问题解决。