We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • WHM API 1 Functions - restartservice
Skip to end of metadata
Go to start of metadata

Description

This function restarts a service, or daemon, on a server.

Note:

In cPanel & WHM version 88, if the user only possesses the clustering ACL then this function can only act on the named service.


Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/restartservice?api.version=1&service=exim&queue_task=0
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/restartservice?api.version=1&service=exim&queue_task=1
 Command Line
whmapi1 restartservice service=exim queue_task=1


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
	"data": {
		"service": "exim"
	},
	"metadata": {
		"version": 1,
		"reason": "OK",
		"output": {
			"raw": "Waiting for exim to restart....finished.\n\nexim (\/usr\/sbin\/exim -bd -q1h) running as mailnull with PID 3280 ( dfile check method)\n\nexim started ok\n"
		},
		"result": 1,
		"command": "restartservice"
	}
}
 Output (XML)
<result>
    <data>
        <service>exim</service>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <output>
            <raw>
                Waiting
 for exim to restart....finished. exim (/usr/sbin/exim -bd -q1h) running
 as mailnull with PID 3328 (pidfile check method) exim started ok
            </raw>
        </output>
        <result>1</result>
        <command>restartservice</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
servicestring

Required

The service to restart.

For a list of possible values, read our Service Manager documentation.

exim

queue_task

boolean

Whether to queue this task.

This parameter defaults to 0.

Note:

We added this parameter in cPanel & WHM version 86.

  • 1  — Queue.
  • 0  — Do not queue.
0

Returns

ReturnTypeDescriptionPossible valuesExample

service

stringThe restarted service.For a list of possible values, read our Service Manager documentation.exim

output

string

The restartservice function's raw output.

A string of raw output.

Note:

In cPanel & WHM version 86 and later, this function returns the following possible values:

  • If the queue_task parameter is 0 — A string of raw output.
  • If the queue_task parameter is 1 — Nothing.
 Click to view...

Waiting for httpd to restart..............finished.\n\nhttpd

(/usr/local/apache/bin/httpd -k start -DSSL) running as root with PID 21379\n
httpd (/usr/local/apache/bin/httpd -k start -DSSL) running as root with PID 21385
\n\nhttpd started ok\n