Checking why a restart is required on Ubuntu

All of the servers that I run for myself or clients have a small script installed which runs every night to download the list of packages and email me with any pending updates. On the servers running Ubuntu, I’ve noticed the following message often appears when I login to process the updates:

*** System restart required ***

There’s never any indication of why I need to restart the system though. Fortunately there is a simple way to find out which packages have caused the message, by running the following command:

cat /var/run/reboot-required.pkgs

Usually the packages involved will be the Linux kernel or a core library such as libc.