Solve the problem of not executing centos7 boot/etc/rc. local

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.