LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2010, 07:11 AM   #1
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Rep: Reputation: 0
Installed/running kernel version


Hi,

how can I check if the running kernel is the latest installed kernel?

I have ym-updatesd running, and I'd like to get notification when a newer kernel has been installed, so that I can (check whats new) and consider re-booting.

uname -r gives running kernel, but how to dig out the latest installed kernel? yum list kernel and rpm -qa kernel (or ls /boot) have the raw data, but there has to be a more straightforward way than parsing those.

cat /var/log/yum.log | grep kernel | grep -i install | tail -1 | awk ... or something?

Now In need to login every now and then (1-x times per week) and check what I have in /boot. This is a server box running 24/7/365.

-Paavo
 
Old 03-17-2010, 07:22 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
You could check the directory where the kernels are kept, usually in /boot/, and that is probably your best option. You could also keep up to date with kernel release cycles so you know when to expect a new one, you could see whether new entries to your bootloader have been added, of course, that could be a nice misuse and hack, but it'd work.
 
Old 03-18-2010, 02:58 AM   #3
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

would something like this detect if I'm running the latest kernel? This is just a test skeleton, if this seems to work the idea is to put the real action where it now says REBOOT.

Id like to avoid listing /boot contents and "guessing" (with my shell script skills...) what is the latest kernel. Also, parsing /boot/grub/menu.lst does not seem to be that easy (to me), if the goal is to have realiable AND simple check.

This is Fedora 12 (64-bit), so it's rpm/yum based.

-Paavo

Update: looks like kernel is kernel-PAE on 32-bit Fedora, so the scipt below works only in 64-bit.

Code:
#!/bin/bash

kernel_rpm=`rpm -q --last kernel | head -1 | awk '{print $1}' | awk -F kernel- '{print $2}'`
kernel_yum=`cat /var/log/yum.log | grep kernel | grep -i install | tail -1 | awk '{print $NF}'`

kernel_run=`uname -r | awk -F .$(uname -p) '{print $1}'`

# echo [$kernel_rpm]
# echo [$kernel_yum]
# echo [$kernel_run]

if [ "$kernel_yum" == "$kernel_rpm" ] ; then
        echo OK, yum and rpm report the same kernel
else
        echo ERROR, yum and rpm DID NOT report the same kernel
fi

if [ "$kernel_run" == "$kernel_rpm" ] ; then
        echo OK, running the latest installed kernel
else
        echo REBOOT, NOT running the latest installed kernel
fi

exit

Last edited by Paavo; 03-20-2010 at 03:37 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lilypond 2.12 upgrade installed but still running old version qianian Linux - Software 0 10-19-2009 05:37 PM
Installed GCC version doesn't match the version the kernel was compiled with AlucardZero Linux - Software 2 02-07-2008 11:24 AM
installed kernel version? cbielke SUSE / openSUSE 3 12-13-2004 02:50 AM
How can I see what Kernel version I am running? carlosinfl Linux - Newbie 3 05-28-2004 02:47 PM
what kernel version am i running? WindozBytes Linux - General 5 11-18-2001 01:54 AM


All times are GMT -5. The time now is 09:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration