Linux Setup Boot service auto start/shutdown Auto Start command

Source: Internet
Author: User

Linux Setup Boot service auto start/shutdown Auto Start command 2012-02-06 15:13

[[email protected] ~]# Chkconfig--list Show services that start automatically
[[email protected] ~]# chkconfig--add * * * Add boot auto-start * * * Service
[[email protected] ~]# chkconfig--del * * * Delete boot auto-start * * * Service


[[Email protected] ~]# Setup can configure commands in the Shell graphics terminal to select the service


[[email protected] ~]# NTSYSV in shell Terminal graphics Configuration Boot service command, option not more than that

Setup, rc.local and chkconfig can be set up in three different ways

First type)
Enter the #setup command into the System service menu, select the service you want to start, such as httpd, then restart the machine or/etc/rc.d./init.d/httpd start

Second type)
Put the boot command into the/etc/rc.d/rc.local file so that you can start the service automatically each time you start, for example, Apache, after compiling Apache, will generate the Apachectl file under the bin of the installation directory, this is a startup script, We just need to add this order to rc.local.
(SuSE has no rc.local.) SuSE can define its own scripts so that if you want to run your own scripts before and after switching the run level, you can create them individually:
/etc/init.d/before.local
/etc/init.d/after.local)
Echo/usr/local/apache/bin/apachectl>>/etc/rc.d/rc.local,
The way to set up the service to start automatically is to include some scripts similar to the following in rc.local:
#sshd
/usr/local/sbin/sshd

#proftpd
/usr/local/sbin/proftpd

#apache
/home/apache/bin/apachectl start

#mysql
/home/mysql/bin/safe_mysqld--port=3306 &

#start Oracle8i Listener First
Su-oracle-c ' lsnrctl start '

#start oracle8i
Su-oracle-c ' Dbstart '

Third type)
Through the chkconfig directive.

Use the Chkconfig command to add a service to the operating levels of the system, as follows:
1 Create a startup script.
For apache,mysql,ssh such software is self-brought, we just have to modify a little bit to support the chkconfig on it.
2 Modifying scripts
We need to add 2 lines to the front of the script to support the Chkconfig command
# chkconfig:2345 08 92
#
# Description:automates A packet filtering firewall withipchains.
#

Chkconfig: The run level that is defined later to enable the start service (for example, to enable 2345 to start the service), and the order in which services are closed and started (the order in which the services are turned off in the example above 8, the order in which the boot is 92)
Descriptions: Description of the change service (the above example is the IPChains packet filter), you can replace the desired

After you modify it, execute it.
CP your script/etc/rc.d/init.d/pin name
chmod 700/etc/rc.d/init.d/Foot Name
Chkconfig--add Foot Name
For example:
Add it to the Linux boot process and run only at level 3, levels 5
[Email protected] init.d]/sbin/chkconfig--add apache-httpd
[Email protected] init.d]/sbin/chkconfig--level Apache-httpdon
After that, we will automatically start and close our service every time we restart the server.

Linux Setup Boot service auto start/shutdown Auto Start command

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.