I am running a server which runs on CentOS with cPanel (latest version) and I have it set to automatically update using yum. Since it needs to be rebooted in order to update the kernel (and possibly other things), I was wondering if there's any way to figure out if a reboot is required?

EDIT: The server is a VPS and it's running on OpenVZ. Because of the way OpenVZ works, there's no /boot/vmlinuz and yum list installed kernel doesn't work either.

  • OpenVZ slices do not have their own kernel and so there is no point in trying to update it. The whole machine just runs one kernel belonging to the host system.
    – goldilocks
    Jan 3, 2015 at 18:59

2 Answers 2


You can try the following bash script from this answer from ServerFault.

LAST_KERNEL=$(rpm -q --last kernel | perl -pe 's/^kernel-(\S+).*/$1/' | head -1)
CURRENT_KERNEL=$(uname -r)

  • as an answer - good, but as a solution - no, this will return REBOOT in case of a custom kernel installed/compiled, kernel is not installed, and other rpm names errors.
    – ADM
    Jul 13, 2014 at 10:02
  • If a package is upgraded which required an upgrade in initrd, a reboot is required but it is the same kernel version.
    – hschou
    Feb 16, 2017 at 22:02

First of all, we print out running kernel version:

# uname -r 

Ok, we have to patch:

# yum update kernel*

Grab the kexec tools:

# yum install kexec-tools

Now we get last installed kernel version release and put it on a var:

# latestkernel=`ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1` 

# echo $latestkernel 

Now we need to load the new kernel version in memory:

# kexec -l /boot/vmlinuz-${latestkernel} --initrd=/boot/initramfs-${latestkernel}.img --append="`cat /proc/cmdline`"

Finally, we can issue a reset:

# kexec -e

..and.. wow, we lost the system! ..Well, not exactly.

The system will “restart without restarting”..something like a fast reboot, without performing BIOS checks (and you know how long can a full system restart last).

# uname -r

It worked!

  • Be aware that kernel reset will perform a connection reset as well, together with resetting your uptime, so if you’re searching for something to grant your uptime record while security patching, well, this is not for you.
  • I should've noted that it is a OpenVZ VPS and therefore /boot/vmlinuz doesn't exist. Is there anyway to get around that? Jun 19, 2013 at 16:20
  • This question can be better answered in Ask Ubuntu.
    – Ashish
    Jun 20, 2013 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .