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