Home > Cpanel/Linux Internals > How do I restart a daemon/service through SSH ?

How do I restart a daemon/service through SSH ?

October 6th, 2009

Most of the services can be restarted from WebHostManager, however sometimes
you will need to restart them from the shell.

You must be logged in as root to do this.

All standard linux services, such as http, ftp, exim, cpanel/whm,
interchange, mysql etc, have init scripts in /etc/rc.d/init.d/

root@host [~]# ls /etc/rc.d/init.d/
./ atd* exim* httpd.tmpeditlib kdcrotate* named* nscd* rawdevices* snmpd* yppasswdd*
../ autofs* filelimits* identd* keytable* netfs* portmap* rstatd* sshd* ypserv*
anacron* bandmin* functions* ipaliases* killall* network* portsentry* rusersd* syslog* ypxfrd*
antirelayd* chkservd* gpm* ipchains* kudzu* nfs* proftpd* rwalld* xfs*
apmd* cpanel3* halt* iptables* lpd* nfslock* radvd* rwhod* xinetd*
arpwatch* crond* httpd@ isdn* mysql* nofsck* random* single* ypbind*

This is typical of what you will find in this directory.

The main ones you should be concerned with are :
cpanel3 - starts/stops cpanel and WHM.
This includes Interchange, cppop, and cluster management services as well.

exim - starts/stops the exim mail server

httpd - starts/stops the apache webserver

mysql - starts/stops the mySQL database server

named - starts/stops the BIND dns server

proftpd - starts/stop the ProFTPD (or pureftpd when that is enabled) ftp server

Using these scripts is very easy. Let’s say that named/bind is down and we need to restart it.

As root, simply type /etc/rc.d/init.d/named start

You should see it start up, with a green [OK] on the left side of the shell/terminal window.

It you see a red [FAILED], check the message log. tail /var/log/messages .

You should be able to see the error where things went wrong.

If you can not fix it yourself, contact shift Incharge.

Some of these services have more options than just start and stop, and other ways to do them.
Let’s say you have a lot of domains using your dns server and you don’t want to stop and restart named just because you edited one domain.

type “ndc reload”. ndc controls the named daemon.

If you make a minor change to the /usr/local/apache/conf/httpd.conf, but don’t want to restart it, type
“/etc/rc.d/init.d/httpd graceful” to do a graceful restart (finishes current requests before killing the child processes).

If you want to learn more about what commands each script offers, you can simply run the script without passing any arguments to it.
root@saturn [~]# /etc/rc.d/init.d/cpanel3
Usage: /etc/rc.d/init.d/cpanel3 {start|stop|status|restart}

This let’s us know we can start, stop, check the running status of the service(s), or restart it.

Cpanel/Linux Internals

  1. No comments yet.
  1. No trackbacks yet.