CentOS setup program start up method

  • 2020-05-14 05:55:32
  • OfStack

On the CentOS system, there are two main ways to set up your own installed program to boot.

1, add the orders of the initiator to/etc/rc d/rc local file, such as the following Settings httpd powered up.


#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
/usr/local/apache/bin/apachectl start

2, add write good startup scripts to the directory/etc/rc d/init d /, and then use the command chkconfig set upon boot.

chkconfig function description: check and set up various services of the system.

Syntax: chkconfig [--add][--del][--list][system services] or chkconfig [--level] < Level code > ][system services][on/off/reset]

--add adds services

--del deletes the service

--list checks the startup status of each service

For example, we set mysql to start from scratch:


# will mysql The startup script goes into all the script run directories /etc/rc.d/init.d In the 
cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

# Change the permissions 
chown root.root /etc/rc.d/init.d/mysqld

# All users can execute, only single root You can modify 
chmod 755 /etc/rc.d/init.d/mysqld

# will mysqld  In the linux Start the management system 
chkconfig --add mysqld

# View all services at each run level 
chkconfig --list mysqld

# As long as you run the level 3 On, everything else is off 
chkconfig --levels 245 mysqld off

For example: after we write the httpd scripts in the/etc/rc d/init d/directory, and use


chkconfig --add httpd
chkconfig httpd on

The command is set to boot.

3, add the orders of the initiator to/etc/rc d/rc sysinit file

Script/etc rc. d/rc. sysinit, complete system services to boot, such as system environment variable is set, set the system clock, load font, check to load the file system, generating system startup log file information, etc

For example, we set the self-starting apache:


echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit

Related articles: