在/etc/rc.d/init.d這個文件中輸入的命令在開機時會執行,所以如果只是簡單語句可以直接寫進去,如果是個腳本,就可以通過這個文件去調用你自己的腳本,經過嘗試,結果開機並沒有執行,然后發現了文件中的這句話:
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
ls -l一下發現確實缺少執行權限,於是執行chmod +x /etc/rc.d/rc.local后再重啟便成功了。