Restart services from the command line

Using the restartsrv script

In case the restart will not happen in WHM, use the command:

/usr/local/cpanel/scripts/restartsrv_*

This will try to restart the service from the command line.

Take note in running this command: Place the correct value for the service in the *.

Direct Service Restart

If this script, /usr/local/cpanel/scripts/restartsrv_* does not restart the service, attempt restarting the service directly.

The following command should be used for servers that run CentOS, CloudLinux™, Red Hat® Enterprise Linux (RHEL) 6, or Amazon Linux. The path to the service should be: /etc/rc.d/init.d/service

/etc/rc.d/init.d/service restart

The command below is for servers that run CentOS 7, CloudLinux 7, or RHEL 7. The service-name is the service that you want to restart:

systemctl restart service-name.service

If the attempt to restart fails, service error logs. To diagnose the issue, check out the service error log. Since the errors were logged differently by the service logs, you have to find the location of the error log. You can check the service’s documentation to find the error log’s location.

The common locations for some service’s error logs are on the list below:

  • Apache web server — /usr/local/apache/logs/error_log
  • BIND nameserver, ProFTP FTP server, Pure-FTP FTP server — /var/log/messages
  • Exim mail transfer agent (MTA) — /var/log/exim_mainlog/var/log/exim_rejectlog/var/log/exim_paniclog
    Note: If /var/log/exim_paniclog file isn’t empty, it means that there are serious problems with Exim and some distributions may not function well.
  • Dovecot® mail server —/var/log/maillog
  • MySQL database server —/var/lib/mysql/hostname.err
    Note: Replace hostname with your server’s hostname.
  • OpenSSH secure shell service — /var/log/messages, /var/log/secure, /var/log/auth

Service Commands

The instructions below show the syntax to use to see the command status, stop, start, and restart of service.

The general syntax or command: service SCRIPT-Name COMMAND

This COMMAND is for the start, stop, status, and restart.

The stop command: service SCRIPT-Name stop

To stop the sshd service, input:service sshd stop

The start command: service SCRIPT-Name start

To start the sshd service, input: service sshd start

The status command: service SCRIPT-Name status

To get current status of the sshd service, enter: service sshd status

The restart command: service SCRIPT-Name restart

To restart the sshd service, enter: service sshd restart


For further details in stopping and restarting Apache and its details, refer to this reading: Apache Stop and Restart

Forcing https on Apache, redirecting one URL to another URL, rewriting requested URLs, limiting access to your site and much more examples on mod_rewrite can be read here: Apache mod_rewrite and Examples

Was this article helpful?

Related Articles