Under Linux, the Start, stop, and restart of a services are usually controlled by scripts in the/ETC/INIT.D directory. However, when you start or change the run level, you are searching for scripts in/ETC/RCX.D. where x is the number at run level. This article explains how to start, close, and modify the running of a service. When you install a new service under Debian, such as Apache2, the installation is done by default and it starts automatically the next time it reboots. But if you don't always need this service, just turn it on when you need it, and you can disable it. Until you need to use, execute the following instructions: /etc/init.d/apache2 start
To do this, you need to first remove all apache2 symbolic links in the/ETC/RCX.D directory, but this method is cumbersome and inefficient. Therefore, we recommend that you use the UPDATE-RC.D command to implement this feature. 1, delete a service if you want to manually disable the Apache2 service completely, you need to remove all the single links in the/ETC/RCX.D. But if you use UPDATE-RC.D, it's very simple: update-rc.d-f apache2 Remove
Parameter-F is a mandatory deletion of symbolic links, even though/etc/init.d/apache2 still exists. Note: This command only disables the service until the service is upgraded. If you want to remain disabled after the service has been upgraded. The following command should be executed: UPDATE-RC.D apache2 Stop 80 0 1 2 3 4 5 6.
2, add a service if you want to add this service again and let it boot automatically, you need to execute the following command: UPDATE-RC.D apache2 defaults
And you can specify the start order of the service: UPDATE-RC.D apache2 defaults 90
You can also control the start and kill sequences in more detail: update-rc.d apache2 defaults 20 80
The previous 20 is the run order level at start, and 80 is the level at kill. Can also be written as: Update-rc.d apache2 start 20 2 3 4 5. Stop 80 0 1 6.
Where 0~6 is run level. The UPDATE-RC.D command is not only for Linux services, but also for scripting scripts that can be set to run automatically with this command. See the article "Simple and efficient firewall scripting" in particular.
like this feature, there's a similar command.
The Chkconfig command can be used to check and set up various services for the system.
This is a program developed by Red Hat Company under the GPL rules to query what system services the operating system will perform in each execution level, including all types of resident services.
Use syntax:
Chkconfig [--add][--del][--list][System Services] or Chkconfig [--level < rank code >][system Services][on/off/reset]
Parameter usage:
–add adds the specified system service, allows the chkconfig instruction to manage it, and adds the relevant data to the system-initiated narrative file.
–del deletes the specified system service, is no longer managed by the Chkconfig command, and deletes the relevant data in the system-initiated narration file.
–level< Level Code > Specify the system service to be opened or closed in which execution level.
Use Example:
Chkconfig–list List all system services
Chkconfig–add httpd Increase httpd service
Chkconfig–del httpd Delete httpd service
Chkconfig–level httpd 2345 on puts httpd on (open) at Run Level 2, 3, 4, 5.
Original address: http://baobeituping.javaeye.com/blog/834495