When you install certain updates (e.g. a new kernel) in Ubuntu Desktop, you get an indication that a reboot is required (in Lucid, the logout icon turns red). How can I check, from the command line, whether an Ubuntu server requires a reboot? I could grep for ‘System restart required’ in |
|||||
|
You can simply check if the file For example, any of these would tell you “no such file” or “file not found” if you do not need to reboot, otherwise (if you need to reboot) the file would exist and these commands would show information about the file:
In a bash script, you can use:
|
|||||||||||||||||||||
|
In the package debian-goodies is a command named checkrestart which is quite useful. Its output can help you avoid a full reboot. |
|||||||||||||
|
Normally if the file
exists you should reboot. You can see if this file is there by using this simple command in gnome-terminal.
|
||||
Aswell as the most direct methods written by others there is a handy indication if you use byobu – a set of scripts to make GNU screen a little more user friendly. It shows a set of information at the bottom of the screen, and that can include whether a reboot is required – along with whether updates are available, the time, uptime, memory used … In this screenshot you can see from the If a reboot is required then this will be indicated by the symbol |
||||
The You can check the content of this file in terminal by using |
||||
If you have the reboot-notifier or update-notifier-common packages installed, then you get the files /var/run/reboot-required and /var/run/reboot-required.pkgs reboot-notifier is newer in Ubuntu Wily and Xenial. Debian stretch, but in jessie-backports update-notifier-common Is older, in all Ubuntu versions including Xenial and Debian Wheezy. Not in Debian Stretch or Jessie. ( There is some background to the reboot-notifier package athttps://feeding.cloud.geek.nz/posts/introducing-reboot-notifier/ ) If you don’t have these packages installed then you can compare the version of the linux package installed, with the version running:
You can see here that the latest installed kernel is 3.16.7-ckt20-1+deb8u4 but the kernel running is 3.16.7-ckt20-1+deb8u3. So this system needs a reboot. The u4 vs u3 right at the end. You might need to scroll the box above. In the /proc/version, it is the version near the end of the line that matters. The very minor version code change is typical of a Debian security kernel update |