the update-rc.d tool is a lower tool that can install or remove run level links. it is usually used when installing service packages to create default run level links.you can use it to configure your own run levels for a service.
The update-rc.d tool does not affect links that are already installed. It works only on links that are not already present in the runlevel directories. In this respect, it cannot turn a
service on or off directly as can sysv-rc-conf. To turn off a service, you would first have to
remove all runlevel links in all the rcn.d directories using the remove option and then add
in the services you want with the start or stop options. This makes turning services on
and off using the update-rc.d tool much more complicated.
You use start and stop options along with the runlevel to set the runlevels at which to start or stop a service. You will need to provide a link number for ordering the sequence in which it will be run. Enter the runlevel followed by a period. You can specify more than one runlevel. The following line will start the web server on runlevel 5. The order number used for the link name is 91. The link name will be S91apache. Be sure to include the sudo command.
sudo update-rc.d apache start 91 5 .
The stop number is always 100 minus the start number. So the stop number for a service with a start number of 91 would be 09:
sudo update-rc.d apache stop 09 6 .
The start and stop options can be combined, like so:
update-rc.d apache 99 start 5 . stop 09 6 .
A defaults option will start and stop the service at a predetermined runlevel. This option can be used to set standard start and stop links for all runlevels. Startup links will be set in runlevels 2, 3, 4, and 5. Stop entries are set in runlevels 0, 1, and 6.
update-rc.d apache defaults
The following command performs the same operation using the stop and start options:
update-rc.d apache 99 start 2 3 4 5 . stop 09 0 1 6 .
The multiuser options will start entries at 2, 3, 4 ,5 and stop them at 1:
update-rc.d apache multiuser
To remove a service you use the remove option. The links will not be removed if the
service script is still present in the init.d directory. Use the -f option to force removal of the
links without having to remove the service script. The following removes all web service
startup and shutdown entries from all runlevels:
update-rc.d –f apache remove
To turn off a service at a given runlevel that is already turned on, you would first have to remove all its runlevel links and the add in the links you want. So, to turn off the Apache
server at runlevel 3, but still have it turned on at runlevels 2, 4, and 5, you would use the
following commands:
update-rc.d –f apache remove
update-rc.d apache 99 start 2 4 5 . stop 09 0 1 3 6 .
Keep in mind that the remove option removes all stop links as well as start ones. So you have to restore the stop links for 0, 1, and 6.
TIP: On Debian and Ubuntu you can use file-rc instead of sysv-rc. The file-rc tool uses a single configuration file instead of links in separate runlevel directories.
No comments:
Post a Comment