Centos 7 about rc.local script command start-up not performed and specify user initiated workaround

Source: Internet
Author: User


1. Boot does not start

In the actual production scenario, we like to install some software services, set the software to boot, set to boot from boot There are two ways:

1) set to chkconfig, You can write a script to view the command to set the boot- up –add indicates that the add program is self-booting and --list represents the view.

for future programs, if you need to use chkconfig boot -up, you need to add three lines to the startup program:

# chkconfig:2345 20 80

#description: Saves and restores system entropy pool for \

# Higher quality random numbergeneration.

the 20,80 in the first row is the startup level and cannot be the same as other programs, so you need to customize the settings.

2) configured in the /etc/rc.local file. Write the startup command of the software service directly in the rc.local file

Note: After editing rc.local file, be sure to give rc.local File Execution permission, otherwise the RC will not be executed at boot time . Local script commands in Files

Chmod+x/etc/rc.d/rc.local

note here that it is /etc/rc.d/rc.local , not /etc/rc.local , if you give /etc/rc.local execution permissions are not valid because the /etc/rc.local is the soft link, the real file is /etc/rc.d/rc.local


2. About specifying user execution script commands in the rc.local file

with the SU Command, the command format:

Su-username-c "Your-cammand", such as:

[Email protected] ~]$ cat/etc/rc.local

#!/bin/bash

# This FILE was ADDED for compatibility purposes

#

# It's highly advisable to create own systemdservices or Udev rules

# To run scripts during boot instead of using Thisfile.

#

# in Constrast to previous versions due to parallelexecution during boot

# This script is not being run after all otherservices.

#

# Please note the must run ' chmod +x/etc/rc.d/rc.local ' to ensure

# That's this script would be executed during boot.

Touch/var/lock/subsys/local

/bin/systemctl Start Iptables.service

#startup MongoDB

/bin/su-xiaoyao-c "/mnt/mongodb/bin/mongod--config/mnt/mongodb/bin/mongodb.conf"

Note: Specify the script (program) directory that the user executes, and the user must have permission to manage the script (program) directory (file).

It is a good idea to take ownership of the script (program) directory to that User:

Chown-r Xiaoyao. Xiaoyao /mnt/mongodb


Centos 7 about rc.local script command start-up not performed and specify user initiated workaround

Related Article

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.