Page tree
Skip to end of metadata
Go to start of metadata

Description

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

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/restartservice?service=httpd
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/restartservice?service=httpd
 Command Line
whmapi0 restartservice service=httpd

Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 0 documentation or run the whmapi0 --help command. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 Output (JSON)
{
   "restart":[
      {
         "result":1,
         "service":"httpd",
         "rawout":"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",
         "servicename":"Apache Web Server"
      }
   ]
}

 Output (XML)
<restartservice>
     <restart>
            <rawout>Waiting for httpd to restart..............finished.
            httpd (/usr/local/apache/bin/httpd -k start -DSSL) 
            running as root with PID 19446
            httpd (/usr/local/apache/bin/httpd -k start -DSSL) 
            running as root with PID 19452
            httpd started ok
            </rawout>
            <result>1</result>
            <service>httpd</service>
            <servicename>Apache Web Server</servicename>
      </restart>
</restartservice>

   

Parameters

ParameterTypeDescriptionPossible valuesExample
servicestring

Required

The service to restart.

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

mysql

 

Returns

ReturnTypeDescriptionPossible valuesExample
restartarray of hashesAn array of hashes that contain service data.This array of hashes includes the rawoutresultservice, and servicename returns. 

rawout

string

The restartservice function's raw HTTP output.

The function returns this value in the restart hash.

A string of raw HTTP data.
 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

 

result

Boolean

The result of the function.

The function returns this value in the restart hash.

  • 1 — The function succeeded.
  • 0 — The function failed
1

service

string

The restarted service.

The function returns this value in the restart hash.

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

servicename

string

The restarted service's full name.

The function returns this value in the restart hash.

A string value.Apache Web Server