How to automatically check for a new kernel

Running the following script under cron and it will notify you your Linode needs rebooting to pick up the latest kernel:

#!/bin/bash

curl -s "https://api.linode.com/?api_key=TODOyourlongLinodeAPIKeyhere&api_action=avail.kernels&isXen=1" | jq '.DATA' | grep "Latest.*$(uname -r)" > /dev/null
if [ $? -eq 1 ]; then
  touch /var/run/reboot-required
  echo "New Linode Kernel is available - Reboot Required" | mail -s "New Linode Kernel is available" TODO@email
fi

3 Replies

Rather than putting an API key on the Linode, you could also use the RSS feed:

https://www.linode.com/rss/kernels.xml

Either way works, all depends what kind of parsing you want to do.

  • Les

> Rather than putting an API key on the Linode, you could also use the RSS feed:

https://www.linode.com/rss/kernels.xml

Either way works, all depends what kind of parsing you want to do.

  • Les

And here's a bash script that uses the rss feed

#!/bin/bash
    curl -s https://www.linode.com/rss/kernels.xml | grep "Latest.*$(uname -r)" > /dev/null
    if [ $? -eq 1 ]
    then
        echo -n 'Not using latest Linode kernel'
    fi

Shows 4.0.2 as the latest for me Latest 64 bit (4.0.2-x86_64-linode56) note the newest kernel isn't always the one marked as latest. A kernel is only given the Latest flag when Linode think it's stable.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct