Issue Overview
I came across a bug/situation, where the needs-restarting utility falsely claims I need to reboot, even though it is a brand new system with a fresh OS, and I have restarted many times.
[root@linux-server ~]# needs-restarting --reboothint
Core libraries or services have been updated:
systemd -> 219-57.el7
linux-firmware -> 20180220-62.2.git6d51311.el7_5
openssl-libs -> 1:1.0.2k-12.el7
kernel -> 3.10.0-862.3.3.el7
glibc -> 2.17-222.el7
dbus -> 1:1.10.24-7.el7
Reboot is required to ensure that your system benefits from these updates.
More information:
https://access.redhat.com/solutions/27943
Troubleshooting steps
The /bin/needs-restarting utility is a python script. So I added some additional verbosity to it
import time
and then some print features:
if opts.reboothint:
needing_reboot = set()
for pkg in my.rpmdb.searchNames(REBOOTPKGS):
print pkg.name
print "Package installation time is %s " % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(pkg.installtime))
print "boot time is %s " % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(boot_time))
if float(pkg.installtime) > float(boot_time):
needing_reboot.add(pkg)
The result was that these packages were installed BEFORE my current system time
[root@linux-server ~]# needs-restarting --reboothint | head -n 3
kernel
Package installation time is 2019-04-11 22:25:53
boot time is 2019-04-11 16:10:32
[root@linux-server ~]# date
Thu Apr 11 16:20:42 AEST 2019
In essence, the kickstart installation occurred prior to NTP time being set. Which normally isn't a problem, however the time set in the factory is not the actual correct time. Therefore, the installation time is after the current system time (and also after the last-boot time)
Resolution
I have three main options available to work around this
- Set the system time manually in BIOS before installing the OS
- run ntpdate in the kickstart pre section to set the time
- ignore the error and wait a day or so before relying on the needs-restarting check