Determine whether a full CentOS 7 reboot is required and which services need to be restarted.
Operating system.
$ cat /etc/centos-release CentOS Linux release 7.6.1810 (Core)
I will use needs-restarting
utility that reports running processes that have been updated.
This utility is provided by the yum-utils
package.
$ yum --cacheonly whatprovides needs-restarting
Loaded plugins: fastestmirror yum-utils-1.1.31-52.el7.noarch : Utilities based around the yum package manager Repo : base Matched from: Filename : /usr/bin/needs-restarting
Use it to determine whether a full reboot is required.
It will return
1
when a reboot is required and give you additional feedback.$ sudo needs-restarting --reboothint
Core libraries or services have been updated: glibc -> 2.17-292.el7 Reboot is required to ensure that your system benefits from these updates. More information: https://access.redhat.com/solutions/27943
$ echo $? 1
$ sudo needs-restarting --reboothint
Core libraries or services have been updated: systemd -> 219-67.el7_7.2 kernel -> 3.10.0-1062.9.1.el7 dbus -> 1:1.10.24-13.el7_6 openssl-libs -> 1:1.0.2k-19.el7 linux-firmware -> 20190429-72.gitddde598.el7 glibc -> 2.17-292.el7 Reboot is required to ensure that your system benefits from these updates. More information: https://access.redhat.com/solutions/27943
$ echo $? 1
It will return
when a reboot is not required.$ sudo needs-restarting --reboothint
No core libraries or services have been updated. Reboot is probably not necessary.
$ echo $?
Use it also to determine services that are affected by updates.
$ sudo needs-restarting --services
rpcbind.service chronyd.service sshd.service systemd-logind.service NetworkManager.service postfix.service tuned.service auditd.service getty@tty1.service crond.service rsyslog.service dbus.service gssproxy.service systemd-udevd.service systemd-journald.service polkit.service
Notice, it will always return ``, so do not use the exit code in this specific case.