restart services

From WebHostingNeeds.com
Jump to: navigation, search

On linux, you can restart a service by using service command.

service service-name restart

For example

To Restart Apache:

service httpd restart

To restarted chkservd

service chkservd restart

chkservd is a service in cpanel server that check services and restart if they are down.

Restart Cpanel:

service service-name restart


Restart Bind:

service named start

Understanding Services

All services in linux have an init script. When linux boot, these init scripts are executed.

Init scripts are stored in the folder

/etc/init.d

All services have a file on this folder.

You can stop or start the services by using these init scripts.

For example, to restart apache, do

/etc/init.d/httpd restart

To restart exim

/etc/init.d/exim restart


Here is files in /etc/init.d/ folder

[[email protected] ~]# cd /etc/init.d
[[email protected] init.d]# ls -l
total 768
drwxr-xr-x   2 root root     4096 Feb 28 04:44 .
drwxr-xr-x  10 root root     4096 Feb 13 22:54 ..
-rwxr-xr-x   1 root root     1128 Feb 21  2005 acpid
-rwxr-xr-x   1 root root      834 Feb 21  2005 anacron
-rwxr-xr-x   1 root root     1694 Sep  2 14:20 antirelayd
-rwxr-xr-x   1 root root     1429 Feb 21  2005 apmd
-rwxr-xr-x   1 root root     4404 Feb 21  2005 arptables_jf
-rwxr-xr-x   1 root root     1176 Apr 26  2006 atd
-rwxr-xr-x   1 root root     2781 May  3  2007 auditd
-rwxr-xr-x   1 root root    16544 May  3  2007 autofs
-rwxr--r--   1 root root     1151 Jul 28  2005 bandmin
-rwxr-xr-x   1 root root     1368 May 14  2007 bluetooth
-rwxr-xr-x   1 root root      899 Oct 14 22:55 chkservd
-r-xr-xr-x   1 root root      893 Apr 20  2007 courier-authlib
-rwxr-xr-x   1 bin  bin      2325 Apr 20  2007 courier-imap
-rwxr-xr-x   1 root root     3414 Feb 13 22:54 cpanel
-rwxr-xr-x   1 root root     1355 May  3  2007 cpuspeed
-rwxr-xr-x   1 root root     1904 Aug  2  2007 crond
-rwx------   1 root root     1432 Jan 18  2007 csf
-rwxr-xr-x   1 root root     2312 May  3  2007 cups
-rwxr-xr-x   1 root root    16898 May  2  2007 diskdump
-rwxr-xr-x   1 root root      917 May  4  2007 dovecot
-rwxr-xr-x   1 root root      968 May 14  2007 dund
-rwxr-xr-x   1 root root     4141 Sep  2 14:20 exim
-rwxr-xr-x   1 root root      808 Feb 28 04:44 filelimits
-rwxr-xr-x   1 root root    10799 Nov 20  2006 functions
-rwxr-xr-x   1 root root     1778 May 17  2006 gpm
-rwxr-xr-x   1 root root     1388 May  3  2007 haldaemon
-rwxr-xr-x   1 root root     6028 Jan 15  2007 halt
-rwxr-xr-x   1 root root     1001 May 14  2007 hidd
-rwxr-xr-x   1 root root     7828 Feb 13 22:54 httpd
-rw-r--r--   1 root root     7854 Jun 24  2007 httpd.tmpeditlib
-rwxr-xr-x   1 root root     2650 Feb 13 22:54 ipaliases
-rwxr-xr-x   1 root root    13763 May  3  2007 ipmi
-rwxr-xr-x   1 root root     7135 Feb 21  2005 iptables
-rwxr-xr-x   1 root root     1487 Feb 21  2005 irda
-rwxr-xr-x   1 root root     1949 May  3  2007 irqbalance
-rwxr-xr-x   1 root root     6183 Feb 21  2005 isdn
-rwxr-xr-x   1 root root      200 Sep 27  2006 keytable
-rwxr-xr-x   1 root root      652 Sep  4  2003 killall
-rwxr-xr-x   1 root root     2095 May  3  2007 kudzu
-rwx------   1 root root     1727 Jan 20  2007 lfd
-rwxr-xr-x   1 root root     1355 Feb 17  2005 lircd
-rwxr-xr-x   1 root root     3097 Nov 11  2005 lm_sensors
-rwxr-xr-x   1 root root     1906 May  5  2007 lvm2-monitor
-rwxr-xr-x   1 root root     1700 May  3  2007 mdmonitor
-rwxr-xr-x   1 root root     1613 May  3  2007 mdmpd
-rwxr-xr-x   1 root root     1746 May  3  2007 messagebus
-rwxr-xr-x   1 root root     1731 May  3  2007 microcode_ctl
-rwxr-xr-x   1 root root    11121 Jul 17  2007 mysql
-rwxr-xr-x   1 root root     5648 Nov 17 09:42 named
-rwxr-xr-x   1 root root    12198 May  3  2007 netdump
-rwxr-xr-x   1 root root     7422 Nov 20  2006 netfs
-rwxr-xr-x   1 root root     1303 May  2  2007 netplugd
-rwxr-xr-x   1 root root     8543 Apr 18  2006 network
-rwxr-xr-x   1 root root     1454 May  3  2007 NetworkManager
-rwxr-xr-x   1 root root     4344 May  3  2007 nfs
-rwxr-xr-x   1 root root     3274 May  3  2007 nfslock
-rwxr-xr-x   1 root root     2171 May  2  2007 nscd
-rwxr-xr-x   1 root root     3586 May  5  2007 ntpd
-rwxr-xr-x   1 root root    17713 May  3  2007 openibd
-rwxr-xr-x   1 root root     7882 May  3  2007 opensmd
-rwxr-xr-x   1 root root     1144 May 14  2007 pand
-rwxr-xr-x   1 root root     4431 Mar  8  2006 pcmcia
-rwxr-xr-x   1 root root     1877 Feb 21  2005 portmap
-rwx------   1 root root     2855 Jan 30  2002 portsentry
-rwxr-xr-x   1 root root     1021 Jan 17  2007 psacct
-rwxr-xr-x   1 root root     2171 Apr 24  2007 pure-ftpd
-rwxr-xr-x   1 root root     2404 Oct 18  2004 rawdevices
-rwxr-xr-x   1 root root     1387 May  3  2007 rdisc
-rwxr-xr-x   1 root root      790 May  3  2007 readahead
-rwxr-xr-x   1 root root      795 May  3  2007 readahead_early
-rwxr-xr-x   1 root root     1777 May 30  2007 rhnsd
-rwxr-xr-x   1 root root     2177 May  3  2007 rpcgssd
-rwxr-xr-x   1 root root     1805 May  3  2007 rpcidmapd
-rwxr-xr-x   1 root root     2153 May  3  2007 rpcsvcgssd
-rwxr-xr-x   1 root root     1010 Feb 21  2005 rwhod
-rwxr-xr-x   1 root root     1547 Feb 21  2005 saslauthd
-rwxr-xr-x   1 root root      825 Jun 19  2007 securetmp
-rwxr-xr-x   1 root root     1175 Jul 10  2002 single
-rwxr-xr-x   1 root root     2247 May  3  2007 smartd
-rwxr-xr-x   1 root root     1671 May  3  2007 snmpd
-rwxr-xr-x   1 root root     1273 May  3  2007 snmptrapd
-rwxr-xr-x   1 root root     1575 Jun 14  2007 spamassassin
-rwxr-xr-x   1 root root     3099 Nov 17 02:29 sshd
-rwxr-xr-x   1 root root     1369 Feb 21  2005 syslog
-rwxr-xr-x   1 root root     1094 Nov 17 07:14 sysstat
-rwxr-x---   1 root pegasus  2321 Aug 12  2006 tog-pegasus
-rwxr-xr-x   1 root root     1880 Aug 12  2006 vsftpd
-rwxr-xr-x   1 root root     1548 May 14  2007 winbind
-rwxr-xr-x   1 root root     1650 May  3  2007 wpa_supplicant
-rwxr-xr-x   1 root root     3554 Jan 23 12:40 xfs
-rwxr-xr-x   1 root root     2497 Aug 22  2005 xinetd
-rwxr-xr-x   1 root root     2822 May  3  2007 ypbind
-rwxr-xr-x   1 root root     1036 May  5  2007 yum
[[email protected] init.d]#


Lets execute exim

[[email protected] ~]# /etc/init.d/exim
Usage: exim {start|stop|restart|status}
[[email protected] ~]#

With not no parameter, it provide help.

To to see status, we use

[[email protected] ~]# /etc/init.d/exim status
exim (pid 3037 3029) is running...
[[email protected] ~]#

This work for all services.