Question: as all know after kernel upgrade (on `RHEL 7`), reboot is necessary in order to update the kernel version

So after reboot we can verify the kernel version by `uname -r`

since we are using scripts for kernel upgrade,

we want to verify what is the right approach that machines are required reboot as results of kernel upgrade

just to mention that `reboot` process isn't immediately after kernel upgrade process, and could be couple of months after kernel upgrade

so, we want to find the right verification that indicate that machine `RHEL7` required reboot

one approach is to verify by `uname -r` the version and comparing that version with installed rpm's as `rpm -qa | grep kernel`

but maybe we can get advice about better indication or better verification

Answer: 
> 
> as all know after kernel upgrade (on RHEL 7), reboot is necessary in order to update the kernel version
> 
> 
> 

no, it's already upgraded; but to run a new kernel, you'll need to load the new kernel if you want to use it. Since Linux is not *that* cool, the only way to do that is effectively a reboot¹.

`yum` comes with a tool to tell you whether *any* of the things you've installed/upgraded require a reboot. Was easy to find, it's called `needs-restarting`. Call it with `-r` to get a meaningful return code.

---

¹ Technically, you could kexec into a new kernel, but none of the running processes, open files, filesystems network … will survive, so you end up with a broken state.
/usr/bin/needs-restarting (in yum-utils) can do this for you.

(e.g., `needs-restarting -r || shutdown +5 "Rebooting post patching"` )

```
Usage:  
    needs-restarting: Report a list of process ids of programs that started  
                    running before they or some component they use were  updated.  

Options:   
   -h, --help        show this help message and exit  
   -u, --useronly    show processes for my userid only  
   -r, --reboothint  only report whether a full reboot is required  
                     (exit code 1) or not (exit code 0)  
   -s, --services    list the affected systemd services only  

```