之前都會把一些每次 CentOS Linux 開機時會執行的一些指令寫在 /etc/rc.d/rc.local 檔案內,但最近卻發現它好像不會執行
# 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 constrast 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
sh /etc/rc.d/firewall.server[@more@]但手動執行 firewall.server 可以正常執行
# sh /etc/rc.d/firewall.server
後來查看一下 /etc/rc.d/rc.local
# ls -l /etc/rc.d/rc.local
-rw-r–r– 1 root root 630 8月 24 11:26 /etc/rc.d/rc.local
發現似乎沒有執行的權限
後來加上了 /etc/rc.d/rc.local 的執行權限,似乎開機時會自動執行了!
# chmod 744 /etc/rc.d/rc.local