寫在rc.local裡面的指令碼開機未執行
阿新 • • 發佈:2018-11-30
問題描述:最近安裝了CentOS7以及中標麒麟7,發現寫在rc.local裡面的指令碼開機未執行
通過ll /etc/rc.local檢視有執行許可權
[[email protected] ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 5月 6 2017 /etc/rc.local -> rc.d/rc.local
解決辦法及思路:
1、檢視rc.local其中第四段明確指出你必須給/etc/rc.d/rc.local賦予執行許可權,來確保在啟動的時候可以執行此指令碼
[[email protected] ~]# vim /etc/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. touch /var/lock/subsys/local mount -o loop /ISO/rhel-server-7.2-x86_64-dvd.iso /mnt/rh7
2、通過ll檢視/etc/rc.d/rc.local確實沒有執行許可權,執行chmod +x /etc/rc.d/rc.local後,再次reboot測試rc.local裡面的指令碼成功執行
[[email protected] ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 532 11月 5 13:47 /etc/rc.d/rc.local