reload
Reloading httpd: [ OK ]
Finally, to stop the web server:
# service
Stopping httpd: [ OK ]
4.6.2. How Does It Work?
Services are managed by scripts in the
If you examine a runlevel directory, you'll see names beginning with K or S , followed by a 2-digit number, followed by a service name:
$ ls
K01rgmanager K36postgresql K90isicom
K01yum K45arpwatch K92ipvsadm
K02NetworkManager K46radvd K94diskdump
K02NetworkManagerDispatcher K50netdump S01sysstat
K05innd K50snmpd S04readahead_early
K05saslauthd K50snmptrapd S05kudzu
K09dictd K50tux S06cpuspeed
...(Lines snipped)...
K35vncserver K85mdmpd S97messagebus
K35winbind K85zebra S98cups-config-daemon
K36dhcp6s K87multipathd S98haldaemon
K36lisa K89netplugd S99local
K36mysqld K89rdisc
All of these files are actually symbolic links to service scripts in
$ cd
$ ls -l
lrwxrwxrwx 1 root root 13 Oct 5 14:37 S90xfs -> ../init.d/xfs
The scripts that start with
The digits in the filename are used to control the sequence in which the scripts are executed. This is essential because some services rely on others; for example, the web server relies on the network being up and running, so the network script must be run first.
When you examine the top of a service script, you will find a comment line containing the keyword chkconfig: followed by three arguments:
$ head
#!/bin/bash
#
# Id:$
#
# xfs: Starts the X Font Server
#
# Version: @(#) /etc/init.d/xfs 2.0
#
# chkconfig: 2345 90 10
# description: Starts and stops the X Font Server at boot time and shutdown.
The first argument ( 2345 ) is a list of the runlevels in which this service will run by default; this information is used to initially set up the system and to handle
When service scripts are called, they are passed a keyword such as start , stop , restart , or reload , indicating the action the script must take.
4.6.3. What About...
4.6.3.1. ...creating my own runlevel?
You can use the
This technique is particularly useful on laptops, which may be used in different locations and need different services in each location.
4.6.3.2. ...creating my own service?
To create a service:
1. Create a service script in
2. Run the command chkconfig --add
You can then configure your service in the same way as any of the other services, using