After reading this post you will know which services need to be restarted after updating one or more RPM packages. Also, you will know if a server reboot is needed after updating one or more RPM packages.
needs-restarting utility of yum
The needs-restarting(1) tool described here can take a considerable amount of running time since it checks many services and library relationships. However, running the needs-restarting tool after any RPM update, such as by rpm or yum, is recommended.
Check Services To Restart
1. To see a list of processes that started running before they or some component they use were updated, do this:
# needs-restarting 2438 : /usr/libexec/hald-addon-generic-backlight 2458 : hald-addon-storage: polling /dev/sr0 (every 2 sec) 2847 : xinetd-stayalive-pidfile/var/run/xinetd.pid 2457 : hald-addon-acpi: listening on acpid socket /var/run/acpid.socket 2452 : hald-addon-input: Listening on /dev/input/event7 /dev/input/event0 /dev/input/event2 /dev/input/event1 27729 : rpc.statd 24992 : /usr/sbin/named-unamed 1 : /sbin/init 972 : /usr/sbin/sshd 12560 : /sbin/udevd-d 2406 : hald-runner 2036 : rpcbind-w 2405 : hald 2178 : irqbalance--pid=/var/run/irqbalance.pid 2070 : /sbin/rsyslogd-i/var/run/syslogd.pid-c5 24450 : /sbin/udevd-d 2763 : tgtd 2819 : /usr/sbin/mcelog--daemon 2766 : tgtd 2930 : crond 589 : /sbin/udevd-d 2979 : /sbin/mingetty/dev/tty6 2977 : /sbin/mingetty/dev/tty5 2975 : /sbin/mingetty/dev/tty4 2339 : dbus-daemon--system 29738 : /usr/sbin/console-kit-daemon--no-daemon 29510 : /sbin/mingetty/dev/tty1 #
2. In this example PID 972 (/usr/sbin/sshd) needs restarting. (pid=972) needs to be restarted, which is provided by sshd service.
# needs-restarting | fgrep 972 972 : /usr/sbin/sshd
3. This executable is provided by the openssh-server RPM package.
# rpm -qf /usr/sbin/sshd openssh-server-5.3p1-123.el6_9.x86_64
# rpm -qf /usr/sbin/sshd -l | fgrep .serv /usr/lib/systemd/system/sshd.service ...
4. Thus restarting sshd service results that /usr/sbin/sshd is removed from the list.
# service sshd restart stopping sshd [ OK ] starting sshd [ OK ]
# needs-restarting | fgrep ssh
If no process needs to be restarted, needs-restarting shows nothing. If something is shown but can not be removed even after restarting relevant services, the system needs to reboot OS.
Check If Server Restart Needed (CentOS/RHEL 7 and later)
Some services cannot be restarted without destablizing the server. To check for these cases, CentOS/RHEL 7 and later support a -r command line switch:
# needs-restarting -r Core libraries or services have been updated: dbus -> 1:1.10.24-7.0.1.el7
Any output from this command form indicates a system reboot is recommended.