Under the Linux operating system, often need to create services that these services be made into a shell script, these services need to be started automatically when the system starts, shut down automatically when closed.
Script to/etc/rc.d/init.d directory will need to start automatically, and then use the command chkconfig–add filename is automatically registered at boot and shut off. Essence
Is generated in the RC0.d-RC6.d directory, a file connection, these shell scripts that connect to the specified file in the/etc/rc..d directory.
Use the syntax:
Chkconfig [–Add][–del][–list][service] or chkconfig [–level <][on/off/reset >][for coding the level system services]
Chkconfig when run without parameters, it displays usage. If the service name, then check whether the services in the current run level to start. If so, returns true, any
False is returned. If after the service name specified on,off or reset, then the chkconfi be changed to specify the service startup information. On and off means that the service is restarted
Start and stop, reset to reset the service startup information, no matter what problems initializing script. On and off switch, the system default run level 3,4,5 only valid, but reset all run level can be effective.
Chkconfig–list # list all system services
Chkconfig–add httpd # add httpd service
Chkconfig httpd–del httpd # delete service
Chkconfig–level httpd 2345 on # httpd at run level 2, 3, 4, 5 cases are on (open)
Chkconfig–list # list of all service start
Chkconfig–list listed mysqld # mysqld service settings
Chkconfig–level 35 mysqld mysqld on # set in grades 3 and 5 for the boot operation services,–level 35 indicates that the action is only implemented in grades 3 and 5, on
Starts off closed
Chkconfig mysqld on setting # mysqld in the grade on, “all levels“ including 2, 3, 4, 5
–Add to increase the specified system service, let the chkconfig command to manage it, and at the start of the narrative related data within the file.
–Del removes the specified system service, no longer managed by the chkconfig command, and delete related data in the system startup files described.
Coding the level of–level< > read the specified system service to perform a hierarchy which opens or closes.
Level 0: off
Level 1: single–user mode
Level 2: no network connections user command line mode
Level 3: multi-user command line mode of network connection
Level 4: not available
Level 5: multi-user mode with graphical interface
Level 6: restart
It is important to note, level option to specify that you want to view is not necessarily the current run level run level. For each run level, there can be only one startup script or stop
Check script. When you switch run levels, init will not restart services that have already started, will not again to stop the service has stopped.
–List displays all the running system services levels of service, if there is a specific service then displays only the system runs a service level
Chkconfig–list [name]: displays all status messages running system services (on or off). If you specify a name, then display only the specified service
In different run levels of the State.
Chkconfig–add name: Add a new service. Chkconfig ensure a start for each run level (s) or killed (k) entrance. If there are missing, you will
Automatically created default init scripts.
Chkconfig–del name: deleting services and related symbols removed from/etc/rc[0-6].d.
Chkconfig [–level levels] name: setting up a service in specified run level is started, stop or reset.
Run the class file:
Each chkconfig management service under the init.d script with two or more lines of notes. The first line tells chkconfig default run level to start with
And start and stop priority. If a default does not run any level of service to start, then use–instead of run level. Describes the services in the second line, you can use \ cross–line comment.
Servername is a launch services
Chkconfig–delete servername to delete a start service
Chkconfig–list view all
Chkconfig–level 3 servername on|off modifying start/stop service