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

rsync同步要开机就启动服务,vi了 /etc/rc.local后重启发现不生效,找了下博客发现这位仁兄说的很清楚。

粘过来记录下。

博客地址:

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

 

执行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添加多条重复的启动命令脚本,也是无效的。

 

posted @ 2020-12-30 11:22  摩尔迦娜  阅读(1872)  评论(0)    收藏  举报