I have a PC running Ubuntu server.
Sometimes when I ssh into it, I get a message that some packages need upgrading.
I upgrade the software by running (as root)
aptitude update && aptitude safe-upgrade
Sometimes that is enough. But sometimes I need to reboot as well, and I am not told this until I ssh in subsequently. How can I find out sooner?
Ideally I'd like to upgrade by running something like
aptitude update && aptitude safe-upgrade &&
if aptitude needs-reboot ; then shutdown -r now ; fi
but the aptitude needs-reboot command does not exist. What should I run instead?
Clarifications:
- Actually I have two PCs, one running 10.04 (lucid) and the other running 11.04 (natty). I'd hope it would be the same solution for both.
- Strictly command line solutions only please. One of these PCs doesn't have a display, and neither of them has a keyboard.