Reboot Reminder In Arch Linux


Reboot is required when Linux kernel is updated. Ubuntu has a nice MOTD that reminds user to reboot the machine. There is a simple implementation for Arch Linux.
Append the following to end of ~/.bashrc
:
versionUpdated=$(vercmp $(pacman -Q linux | cut -d " " -f 2) $(uname -r))
if [ $versionUpdated -ne 0 ]; then
HIGHLIGHT='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${HIGHLIGHT}Linux version changed, reboot needed.${NC}"
fi
I am using pacman -Q linux | cut -d " " -f 2
to extract installed kernel version. If you are using other distro, you will need to modify this part. vercmp
is also Arch-specific command.
I am using non-zero (-ne
) comparison, so it will display reminder message whenever there is changes in kernel version (both upgrade and downgrade). Font color is yellow, you can change it to a different color.
Reference: https://bbs.archlinux.org/viewtopic.php?id=173508
Subscribe to my newsletter
Read articles from Hong directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Hong
Hong
I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)