Linux boot service and Chkconfig use Method (RPM)

Source: Internet
Author: User
Tags naming convention

each service managed by Chkconfig needs to add two or more lines of comments to the script under the corresponding/ETC/RC.D/INIT.D.
The first line tells Chkconfig the run level of the default startup and the priority of start and stop. If a service does not start at any run level by default, use-instead of run-level.
The second line describes the service, which you can annotate with \ cross-line.
For example, Random.init contains three rows:
# chkconfig:2345 20 80
# description:saves and restores system entropy pool for \
# higher quality random number generation.
Indicates that the random script should start at run Level 2, 3, 4, 5, start with a priority of 20, and stop priority 80.

Http://www.jb51.net/LINUXjishu/58524.html

1. Service overview Under the Linux operating system, it is often necessary to create services that are made into shell scripts that need to be started automatically when the system is started and shut down automatically when it is shut down. You will need to automatically start the script in the/ETC/RC.D/INIT.D directory and then use the command chkconfig--add filename to automatically register the boot and shutdown shutdown. The essence is to generate some file connections in the RC0.D-RC6.D directory that connect to the shell script for the specified file in the/ETC/RC.D/INIT.D directory.
Oracle Auto Start and stop under article Linux (i), Oracle Auto Start and stop under Linux (ii) there are some descriptions for creating services.
2. Create a service manually under the/ETC/RC.D/INIT.D directory, create a shell script with the file name Auto_run. Set the script's run permissions chmod +x auto_run. The file connection is then created separately under the RC0.D-RC6.D directory. Ln-s/etc/rc.d/init.d/auto_run/etc/rc.d/rc2.d/s99auto_run ln-s/etc/rc.d/init.d/auto_run/etc/rc.d/rc3.d/s99auto_ Run Ln-s/etc/rc.d/init.d/auto_run/etc/rc.d/rc5.d/s99auto_run ln-s/etc/rc.d/init.d/auto_run/etc/rc.d/rc0.d/ K01auto_run ln-s/etc/rc.d/init.d/auto_run/etc/rc.d/rc6.d/k01auto_run
When the system starts, it runs the Auto_run and adds the start parameter, which is equivalent to executing the command auto_run start. When the system shuts down, Auto_run is run and the stop parameter is added, which is equivalent to running the command Auto_run stop.
The 6 commands for creating a connection can be done with the command chkconfig--add Auto_run, which is much simpler and less prone to error. Here's an introduction to the Chkconfig command.
3.chkconfig command usage Syntax: chkconfig--list [name] chkconfig--add name chkconfig--del name Chkconfig [--level levels] name < On|off|reset> Chkconfig [--level levels] Name
Description: Chkconfig provides a simple command-line tool to help administrators directly manipulate numerous symbolic links under the/ETC/RC[0-6].D directory hierarchy. This command is used by the Chkconfig command to provide authorization on the IRIX operating system. Instead of maintaining configuration information directly under the/ETC/RC[0-6].D directory, you manage the linked files directly under/etc/rc[0-6]. The configuration information in the run-level directory notifies you of which services will be started initially. Chkconfig has five distinct features: Adding a new feature to the management, removing a feature, listing the startup information for the current service, changing the startup information for a service, and detecting the startup status of a particular service. When Chkconfig runs without parameters, it displays how it is used. If only one service name is given, it will detect if the service name has been configured to the current runlevel. If it is already configured, returns TRUE, otherwise false. The--level option can be used to query multiple runlevel rather than just one.         if on is specified after the service name, off or Reset,chkconfig will change the startup information for the specified service. The on or off flag service is opened or stopped, especially when the runlevel is changed. The reset flag resets the service's startup information.         by default, the on or off option affects only 2, 3, 4, and 5, and reset affects all run levels. The--level option can be used to specify which RunLevel receives the impact. Note: For each service, there is a start and an end angle for each run level. When a run level is on or off, Init does not restart a service that is already running and does not stop a service that is not running. Opt.:       --level levels                specifies a run-level appropriate operation. The range is 0-7.        --add name              &nBsp Add a new service.        --del name                Delete a service        --list name                Display of services RUNLEVEL FILES Each service managed by Chkconfig requires two or more lines of comments in the corner book under its INIT.D directory. The first line tells Chkconfig what run-level services can start by default, that is, the start or end priority level. If the service does not have a default level, the build will start at all RunLevel. The A – will be used instead of the run-level list. The second comment line includes a description of the service, which can be expanded to multiple lines by means of a backslash symbol.
For example, the first three lines of Auto_run are as follows: #!/bin/sh #chkconfig: 2345 #description: The first line of Auto_run tells the shell that the system uses, so the shell script is like this. The second line, chkconfig after the three parameters 2345,80 and 90 tells the Chkconfig program, need to RC2.D~RC5.D directory, create a file name S80auto_run, connect to/etc/rc.d/ The Auto_run script under the INIT.D directory. The first character is S, when the system starts, run the script auto_run, it will add a start parameter, tell the script, is now the startup mode. At the same time in the RC0.D and RC6.D directory, create the name of K90auto_run file connection, the first character is K, a system in the shutdown system, will run Auto_run, add a stop, tell the script, is now off mode. Note that the above three lines are in, the ground two, the third row is necessary, otherwise when running Chkconfig--add Auto_run, will be error.
4. Common error "service does not support Chkconfig": note check the front of the script for a complete two lines: #chkconfig: 2345 #description: Auto_run in front of the script these two lines are not few, Otherwise, you cannot chkconfig the command to report an error. If the running Chkconfig always error, if the script is not a problem, I suggest, directly under RC0.D~RC6.D to create a file connection to the script to resolve, the principle is the same.

http://blog.csdn.net/chenxiaohua/article/details/4056302

Linux system has 7 runlevel (runlevel) Run Level 0: System down state, the system default RunLevel cannot be set to 0, otherwise it will not start run Level 1: Single user working status, root privilege, for system maintenance, prohibit remote login run Level 2: Multiuser State (no NFS Run Level 3: Full multiuser State (with NFS), login to console command line mode run Level 4: System unused, keep RunLevel 5:x11 console, log in to GUI mode run Level 6: Normal shutdown and restart, default RunLevel cannot be set to 6, otherwise it will not start normally

The operating level principle: 1. There are many server scripts under directory/ETC/RC.D/INIT.D, commonly referred to as Service 2. Under/ETC/RC.D There are 7 directories named RCN.D, corresponding to the system's 7 RunLevel 3. RCN.D directories are symbolic link files that point to a service script file under the INIT.D directory, with a naming convention of k+nn+ service name or s+nn+ service name, where NN is a two-digit number. 4. The system will enter the corresponding RCN.D directory according to the specified run level and retrieve the link file under the directory in the order of file name for files beginning with K, the system will terminate the corresponding service for files beginning with S, the system will start the corresponding service 5. View Run level by: RunLevel 6. Go to other runlevel using: Init N 7. Also init0 for shutdown, init 6 reboot system

http://blog.csdn.net/chenxiaohua/article/details/4054861

Linux boot service and Chkconfig use Method (RPM)

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.