- The service may be crashing or stalled
- The load the process is causing on the server might be too high
- A restart might be needed to produce a configuration change to go into effect.
- CentOS 6
- CentOS 7
- most newer Ubuntu or Debian servers.
Note
For this article, general program names are bolded and italicised, binary commands or operands are highlighted in blue.
- With the first method, we use the service command, also known as systemd, to issue commands to the desired service. For Apache, this looks like service httpd restart will issue a restart command to Apache. You can check to see if you are able to restart services this way by running which service. CentOS 7 uses this method by default, CentOS 6 has it available, and it is also available on other major operating systems.
- An older method is to call an init script on the server, known as the upstart method. An upstart command looks like /etc/init.d/httpd restart, which will issue a restart command to Apache also. You can check to see if you can use the init scripts by listing the scripts inside the init.d directory with ls /etc/init.d/. CentOS 5 and 6 used this type of service control by default, as do other aging OSes. Since this is an older method, we won’t discuss it in this article.
- Finally, on cPanel machines, there are service restart scripts provided by cPanel that begin with /scripts/restartsrv_. For instance, the module to restart Apache is /scripts/restartsrv_httpd. This script performs a clean restart of Apache. If your web server has cPanel installed, these scripts are available for use and will always use the proper restart method for your operating system. This method is particularly helpful when the service name can vary based on the engine in use, such as proftpd or pure-ftpd for the FTP client; both use /scripts/restartsrv_ftpd and cPanel selects the appropriate service automatically. You can list the available scripts by running ls /scripts/restartsrv_*.

Note
cPanel has a background daemon called chkservd, which a daemon that checks to see if specific services are running. If you stop a service that is monitored, like Apache, and chkservd finds out, it will assume the service died and will attempt to restart it. Keep this in mind if you stop any services from the command line, and if needed, turn off chkservd from inside of WHM before you start. Make sure to turn it back on when done.
Apache If you are making configuration changes to Apache from the command line, such as creating new include files or optimizations, restarting the service is necessary for the new configuration to be operational. Additionally, if Apache (or httpd) is causing undue load on the server, restarting it usually kills its child processes and starts over with new ones, alleviating memory usage.
# service httpd
usage: httpd {start|stop|restart|fullstatus|status|graceful|configtest|help}
The usage flags may not always make sense to you when printed on the command line. Here is a basic outline of what they mean for Apache. These same general descriptions can apply to other services that use the same usage flags (though some may be Apache-specific).
start | start httpd |
startssl | start httpd with SSL enabled |
stop |
stop httpd |
restart |
restart httpd if running by sending a SIGHUP or start if not running |
fullstatus | dump a full status screen; requires lynx and mod_status enabled |
status | dump a short status screen; requires lynx and mod_status enabled |
graceful | do a graceful restart by sending a SIGUSR1 or start if not running |
configtest | do a configuration syntax test |
help | list the commands available |
# service httpd status
httpd (pid 74669) is running…
The cPanel restart script is essentially the same as service httpd restart:
# /scripts/restartsrv_httpd
Waiting for “httpd” to restart gracefully …
Mail
On cPanel servers the default mail service is exim. Configuration or include changes to exim will require a restart to take effect.
# service exim
Usage: exim {start|stop|restart|status}
On Plesk servers, the default mail service is qmail instead.
# service qmail
Usage: qmail {start|stop|status|reload|condrestart|restart}
SSH
Any change to the SSH configuration file (such as changing the SSH port) requires a restart to the server daemon to take effect. Restarting sshd does not normally break SSH connections, but if you do change the SSH port, make sure you have opened the right ports in your firewall and are ready to make a new connection if needed!
# service sshd
Usage: sshd {start|stop|restart|reload|condrestart|status}
FTP
On cPanel servers the default FTP program is pure-ftp. Any configuration changes to pure-ftp will require a restart to take effect. The cPanel restart script is convenient in this instance, as we covered earlier, even if the FTP program changes through cPanel, the restartsrv_ftpd script will restart the right service.
# service pure-ftpd
Usage: pure-config.pl {start|stop|restart|condrestart|status}
# /scripts/restartsrv_ftpd
Mysql
Mysql is mostly often restarted for configuration changes. Some newer machines will use mariadb instead of mysql or mysqld, though MariaDB normally responds to service requests made through systemd for MySQL as well. Again, the cPanel restart script is handy for cPanel servers, because usage either mariadb or mysql, /scripts/restartsrv_mysql will restart the database engine.
# service mysql
Usage: mysql (start|stop|restart|reload)
# /scripts/restartsrv_mysql
Firewall
On managed Liquidweb servers, the firewall of choice is CSF. The CSF firewall interacts with the iptables service. Any configuration changes made to CSF the service must need a restart for the changes to take effect. However, you should not use the systemd or init scripts for this. CSF has a special restart procedure:
# csf -ra
If you try to use the service command, CSF will warn you not to:
# service csf restart
This script should ONLY be used by the init process. To restart csf use the CLI command 'csf -r'
Cron
Within Linux, the Cron service controls the scheduled tasks that run on the server. Stopping the Cron service will result in schedule task to be skipped. Unlike other services, the cron service does not need a restart if there is an additional cron added; it is generally only restarted when there is a change to the system clock or timezone, or when crons are not running due to various reasons.
# service crond
Usage: crond {start|stop|status|reload|restart|condrestart}
DNS
The named service is the default nameserver daemon for cPanel servers. If you run a different daemon, like MyDNS or NSD, use these names instead of ‘bind’ below.
# service bind
Usage: named {start|stop|status|restart|try-restart|reload|force-reload}
# /scripts/restartsrv_bind