Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Amazon Linux - Check If Need Reboot

Below is a BASH script you can use to tell you whether you need to reboot your instance in order to use a later kernel.

#!/bin/bash

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

if [ $LAST_KERNEL != $CURRENT_KERNEL ]; then 
    echo 'reboot'; 
else 
    echo 'no'; 
fi
Last updated: 4th January 2023
First published: 16th August 2018