Recipe 7.9. Manually Starting and Stopping Services
7.9.1 Problem
You need to start, stop, or restart a
service, but you don't want to make it permanent.
Maybe your network connection has wedged or your web server has died.
Or you changed the configuration file for a service, and need to
restart it to activate the changes. Or you are testing a new service,
so you want to start it up only when you're testing
it.
7.9.2 Solution
Run the program's startup script in
/init.d. Find the appropriate script in
init.d, then read the script to see the
available options. For example, restarting networking is a common
need. Take a look in /etc/init.d/networking:
echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"
There's a line like this in every
init script. Another way to get this information
is to run the script with no arguments:
# /etc/init.d/networking
Usage: /etc/init.d/networking {start|stop|restart|force-reload}
So, to stop networking, use the command:
# /etc/init.d/networking stop
7.9.3 Discussion
For any program that has a startup script, it is preferable to use
the script, rather than executing the program's
binary, because the script includes include error and file checking,
and any needed conditional tests.
|