6.1.2 Controlling a Service on CentOS or RHEL 6.x

Table of Contents Previous Next



On version 6.x of RHEL or CentOS Linux, you can control a service at the command line with the service command. The service command can be used to manage an Advanced Server cluster, as well as the services of component software installed with Advanced Server.
Using the service command to change the status of a service allows the Linux service controller to keep track of the server status (the pg_ctl command does not alert the service controller to changes in the status of a server). The command must be in your search path and must be invoked with superuser privileges. Open a command line, and issue the command:
service service_name action
The Linux service command invokes a script (with the same name as the service) that resides in /etc/init.d. If your Linux distribution does not support the service command, you can call the script directly by entering:
/etc/init.d/service_name action
service_name specifies the name of the service.
action specifies the action taken by the service command. Specify:
start to start the service.
stop to stop the service.
condstop to stop the service without displaying a notice if the server is already stopped.
restart to stop and then start the service.
condrestart to restart the service without displaying a notice if the server is already stopped.
try-restart to restart the service without displaying a notice if the server is already stopped.
status to discover the current status of the service.


Table of Contents Previous Next