Solve the problem of not executing centos7 boot/etc/rc. local
Background: Recently, a new server is deployed on the client, and the system is Centos7. I wrote a script for starting the system. The detected/etc/rc. local won't be started and executed, so I checked the/etc/rc. local file carefully and found the cause of the problem.
#!/bin/bash
#THISFILEISADDEDFORCOMPATIBILITYPURPOSES
#
#Itishighlyadvisabletocreateownsystemdservicesorudevrules
#torunscriptsduringbootinsteadofusingthisfile.
#
#Inconstrasttopreviousversionsduetoparallelexecutionduringboot
#thisscriptwillNOTberunafterallotherservices.
#
#Pleasenotethatyoumustrun'chmod+x/etc/rc.d/rc.local'toensure
#thatthisscriptwillbeexecutedduringboot.
Translation:
# This file is added for compatibility issues.
#
# We strongly recommend that you create your own systemd service or udev rules to run scripts at startup instead of using this file.
#
# This script will not be executed after all other services compared with the parallel execution during previous version boot.
#
# Remember, you must execute "chmod + x/etc/rc. d/rc. local" to ensure that this script is executed during boot.
So I confirmed the permission for/etc/rc. local.
[root@localhost~]
#ll/etc/rc.local
Lrwxrwxrwx.1rootroot13 October
/etc/rc
.
local
->rc.d
/rc
.
local
[root@localhost~]
#ll/etc/rc.d/rc.local
-Rw-r --. 1rootroot477, December 7, June 10
/etc/rc
.d
/rc
.
local
/Etc/rc. d/rc. local has no execution permission, so it is executed according to the description.
chmod
+x
/etc/rc
.d
/rc
.
local
After the restart, it is found that/etc/rc. local can be executed.
It is estimated that this method will be discarded as the version is upgraded.