How to check whether CentOS / RHEL needs a complete reboot

I’m utilizing a CentOS/RHEL 6/7/Eight server. How do I examine from the command line if a reboot is required for my CentOS host? How do I examine if a bunch powered by CentOS Enterprise Linux must reboot after working the yum replace command?

We are able to rapidly examine if CentOS / RHEL wants reboot utilizing a command-line possibility. Allow us to discover out whether or not a full CentOS Linux reboot is required and which Linux providers have to be restarted on the host. We’re going use the needs-restarting command. It report a listing of course of ids of applications that began working earlier than they or some element they use had been up to date.

ADVERTISEMENTS

Putting in needs-restarting utility to examine if CentOS / RHEL wants reboot

Run the next yum command:
# yum whatprovides needs-restarting

How to check whether CentOS / RHEL needs a complete reboot
Outputs from my CentOS 8:CentOS-8 – AppStream 3.Three MB/s | 5.Eight MB 00:01
CentOS-8 – Base 2.1 MB/s | 2.2 MB 00:01
CentOS-8 – Extras 14 kB/s | 7.Three kB 00:00
yum-utils-4.0.12-3.el8.noarch : Yum-utils CLI compatibility layer
Repo : BaseOS
Matched from:
Filename : /usr/bin/needs-restarting

Now all it’s important to do is set up yum-utils as follows:
# yum set up yum-utils

Final metadata expiration examine: 0:00:47 in the past on Tue Sep 8 20:13:44 2020.
Dependencies resolved.
===============================================================================
Package deal Arch Model Repository Dimension
===============================================================================
Putting in:
yum-utils noarch 4.0.12-3.el8 BaseOS 66 okay
Putting in dependencies:
dnf-plugins-core noarch 4.0.12-3.el8 BaseOS 64 okay
python3-dateutil noarch 1:2.6.1-6.el8 BaseOS 251 okay
python3-dnf-plugins-core noarch 4.0.12-3.el8 BaseOS 203 okay
python3-six noarch 1.11.0-8.el8 BaseOS 38 okayTransaction Abstract
===============================================================================
Set up 5 Packages

Complete obtain dimension: 622 okay
Put in dimension: 1.Three M
Is that this okay [y/N]: y
Downloading Packages:
(1/5): python3-dateutil-2.6.1-6.el8.noarch.rpm 1.6 MB/s | 251 kB 00:00
(2/5): python3-six-1.11.0-8.el8.noarch.rpm 1.Three MB/s | 38 kB 00:00
(3/5): dnf-plugins-core-4.0.12-3.el8.noarch.rp 320 kB/s | 64 kB 00:00
(4/5): yum-utils-4.0.12-3.el8.noarch.rpm 1.1 MB/s | 66 kB 00:00
(5/5): python3-dnf-plugins-core-4.0.12-3.el8.n 675 kB/s | 203 kB 00:00
——————————————————————————-
Complete 898 kB/s | 622 kB 00:00
Working transaction examine
Transaction examine succeeded.
Working transaction check
Transaction check succeeded.
Working transaction
Making ready : 1/1
Putting in : python3-six-1.11.0-8.el8.noarch 1/5
Putting in : python3-dateutil-1:2.6.1-6.el8.noarch 2/5
Putting in : python3-dnf-plugins-core-4.0.12-3.el8.noarch 3/5
Putting in : dnf-plugins-core-4.0.12-3.el8.noarch 4/5
Putting in : yum-utils-4.0.12-3.el8.noarch 5/5
Working scriptlet: yum-utils-4.0.12-3.el8.noarch 5/5
Verifying : dnf-plugins-core-4.0.12-3.el8.noarch 1/5
Verifying : python3-dateutil-1:2.6.1-6.el8.noarch 2/5
Verifying : python3-dnf-plugins-core-4.0.12-3.el8.noarch 3/5
Verifying : python3-six-1.11.0-8.el8.noarch 4/5
Verifying : yum-utils-4.0.12-3.el8.noarch 5/5

Put in:
dnf-plugins-core-4.0.12-3.el8.noarch
python3-dateutil-1:2.6.1-6.el8.noarch
python3-dnf-plugins-core-4.0.12-3.el8.noarch
python3-six-1.11.0-8.el8.noarch
yum-utils-4.0.12-3.el8.noarch

Full!
[[email protected] ~]#

Checking if CentOS wants a full reboot

The syntax is:
# needs-restarting

examine whether or not a full reboot is required for CentOS host

Be certain the next command inform whether or not a full reboot is required (exit code 1) or not (exit code 0). The syntax is:
# needs-restarting –reboothint
# needs-restarting -r
# echo $? # see exit standing #
Pattern session:

No core libraries or providers have been up to date.
Reboot might be not mandatory.

Run the next on CentOS Eight to replace put in packages for safety:
# yum -y replace

yum replace -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
Resolving Dependencies
–> Working transaction examine
—> Package deal curl.x86_64 0:7.29.0-57.el7 will likely be up to date
—> Package deal curl.x86_64 0:7.29.0-57.el7_8.1 will likely be an replace
—> Package deal dbus.x86_64 1:1.10.24-13.el7_6 will likely be up to date
—> Package deal dbus.x86_64 1:1.10.24-14.el7_8 will likely be an replace
—> Package deal dbus-libs.x86_64 1:1.10.24-13.el7_6 will likely be up to date
—> Package deal dbus-libs.x86_64 1:1.10.24-14.el7_8 will likely be an replace
—> Package deal libcurl.x86_64 0:7.29.0-57.el7 will likely be up to date
—> Package deal libcurl.x86_64 0:7.29.0-57.el7_8.1 will likely be an replace
—> Package deal systemd.x86_64 0:219-73.el7_8.6 will likely be up to date
—> Package deal systemd.x86_64 0:219-73.el7_8.9 will likely be an replace
—> Package deal systemd-libs.x86_64 0:219-73.el7_8.6 will likely be up to date
—> Package deal systemd-libs.x86_64 0:219-73.el7_8.9 will likely be an replace
–> Completed Dependency DecisionDependencies Resolved

===============================================================================
Package deal Arch Model Repository Dimension
===============================================================================
Updating:
curl x86_64 7.29.0-57.el7_8.1 updates 271 okay
dbus x86_64 1:1.10.24-14.el7_8 updates 245 okay
dbus-libs x86_64 1:1.10.24-14.el7_8 updates 169 okay
libcurl x86_64 7.29.0-57.el7_8.1 updates 223 okay
systemd x86_64 219-73.el7_8.9 updates 5.1 M
systemd-libs x86_64 219-73.el7_8.9 updates 416 okay

Transaction Abstract
===============================================================================
Improve 6 Packages

Complete obtain dimension: 6.Four M
Downloading packages:
Delta RPMs disabled as a result of /usr/bin/applydeltarpm not put in.
(1/6): dbus-1.10.24-14.el7_8.x86_64.rpm | 245 kB 00:00
….

……
Verifying : systemd-219-73.el7_8.6.x86_64 12/12

Up to date:
curl.x86_64 0:7.29.0-57.el7_8.1 dbus.x86_64 1:1.10.24-14.el7_8
dbus-libs.x86_64 1:1.10.24-14.el7_8 libcurl.x86_64 0:7.29.0-57.el7_8.1
systemd.x86_64 0:219-73.el7_8.9 systemd-libs.x86_64 0:219-73.el7_8.9

Full!

See if a reboot is neeed after putting in RHEL or CentOS Linux updates

All you could do is:
# needs-restarting -r

Core libraries or providers have been up to date:
dbus -> 1:1.10.24-14.el7_8
systemd -> 219-73.el7_8.9

Reboot is required to make sure that your system advantages from these updates.

Extra info:
https://entry.redhat.com/options/27943

Right here is how I examine if my CentOS 7 field wants reboot:
# needs-restarting
# needs-restarting -r
# needs-restarting -r >/dev/null
# echo $?
# [ $(needs-restarting -r >/dev/null ) ] || echo “Reboot $HOSTNAME to put in kernel or core libs.”

How to check whether CentOS / RHEL needs a complete reboot
Associated: Reboot CentOS Linux desktop or RHEL server utilizing any one of many following command:
# shutdown -r now
# reboot
# systemctl reboot

Ansible reboot Linux machine or server with playbooks

Conclusion

You realized the best way to decide if up to date binaries that want restarting on a CentOS or RHEL host utilizing the command-line possibility. To see assist, kind:
$ needs-restarting –help

🐧 Get the newest tutorials on SysAdmin, Linux/Unix, Open Supply/DevOps subjects:

ADVERTISEMENTS

needs-restarting ansible,dnf needs-restarting,restart rpm,linux updates that require reboot,sudo yum update reboot,needs-restarting ubuntu,check reboot required centos,does yum update restart services,centos 7 reboot needed,needs-restarting: error: no such option: -r,how to check reboot logs in linux,linux reboot count,last reboot command windows,linux last reboot still running,output of last reboot,how to check who rebooted the server in linux,yum check if reboot required,which packages require a system reboot after update?,needs-restarting rhel 8,does yum update require reboot,ansible needs-restarting,needs-restarting script,needs-restarting command not found