CentOS RHEL – reboot after kernel update or if reboot needed
Yum-cron is used to update the server automatically. This service will update the server with all the packages or only the security patches as configured on /etc/yum/yum-cron.conf
But, the yum-cron lack in reboot feature. If any packages, say kernel, glibc or gcc require a reboot of the server then we have to do the reboot manually.
We can solve this issue by adding a simple cron to the server. This cron will check if any package requires reboot of the server, below is the cron command and the cron.
0 5 * * * /usr/bin/needs-restarting -r || shutdown -r