日历

2018年八月
« 7月    
 12345
6789101112
13141516171819
20212223242526
2728293031  

最近评论

    linux企业应用

    centos7 下rc.local里的命令不执行

    一直没怎么用centos7,今天在rc.local文件里添加一个开始执行的服务,结果开机后服务没有启动,仔细一看,原来rc.local已经变了

    [root@localhost ~]# cat /etc/rc.d/rc.local
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run ‘chmod +x /etc/rc.d/rc.local’ to ensure
    # that this script will be executed during boot.
    #翻译下
    #这个文件是为兼容性而添加的
    #在开机过程中强烈建议创建自己的systemd服务或udev规则来运行脚本,而不是使用此文件
    #和以前版本相比,此脚本将不会在其它服务后运行(简而言之centos7中rc.local不是最后启动了)
    #记住,必须运行“chmod +x/etc/rc.d/rc.local”命令来确保启动过程中执行此脚本.
    #(简而言之centos7中rc.local要手动添加可以行权限,开机后此文件才能被执行)
    touch /var/lock/subsys/local
    /etc/init.d/red5 start
    [root@localhost ~]# ll /etc/rc.d/rc.local
    -rw-r–r–. 1 root root 496 Jun  9 08:39 /etc/rc.d/rc.local
    [root@localhost ~]# chmod 755 /etc/rc.d/rc.local
    [root@localhost ~]# ll /etc/rc.d/rc.local
    -rwxr-xr-x. 1 root root 496 Jun  9 08:39 /etc/rc.d/rc.local

    添加权限后,reboot确认一下,在rc.local中需要启动的任务开机自启了。

    评论已关闭。