Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos 7 about rc.local script command boot not executed and specified

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Boot does not start.

In the actual production scenario, we like to set the software to boot after installing some software services. There are two ways to set it to boot:

1) if it is set to chkconfig, you can write a script to view the command to set boot self-startup-add means to add the program self-starting,-- list means to view.

If future programs need to boot with chkconfig, 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.

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

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

Note: after editing the rc.local file, be sure to give the rc.local file execution permission, otherwise the script commands in the rc.local file will not be executed when you boot.

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 permission, it is invalid because / etc/rc.local is a soft link and the real file is / etc/rc.d/rc.local.

two。 About specifying users to execute script commands in the rc.local file

You can use the su command in the command format:

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

[jiakeke@mongodb ~] $cat / etc/rc.local

#! / bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is 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 will NOT be run after all otherservices.

#

# Please note that you must run 'chmod + x bind ETC. RC. d RC. local' to ensure

# that this script will 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 executed by the user, who must have permission to manage the script (program) directory (file).

It is best to give ownership of the script (program) directory to the user:

Chown-R xiaoyao.xiaoyao / mnt/mongodb

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report