linux中rc.local设置开机自启没有生效

执行ll /etc/rc.local命令,发现/etc/rc.local映射文件是/etc/rc.d/rc.local

再ll /etc/rc.d/rc.local发现这个文件没有执行权限(少了x);

其实vi  /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.

所以执行chmod +x  /etc/rc.d/rc.local命令后,启动可以执行这个文件了。

但是还有一个问题,需要保证rc.local文件里面执行的脚本都是可执行的,否则依然无效。

另外如果在rc.local添加多条重复的启动命令脚本,也是无效的。

转自https://www.cnblogs.com/link01/p/12165245.html

原文地址:https://www.cnblogs.com/hark0623/p/14918216.html