Find services that require a restart

Ubuntu offers a live patching utility that allows kernel patches to be installed without requiring a system restart to be applied. Read more about online patching in this post about patching. That said, in many cases other services or processes on your system may need to be restarted after an upgrade.

Finding services that need to be restarted in Ubuntu

Install debian-goodies

sudo apt update
sudo apt install debian-goodies

Now just run

sudo checkrestart

This command will output a list of processes and services that need to be restarted.

Update – 12/26/2016

I just discovered that there is another Debian/Ubuntu program that will not only check for services that need a restart but also restart them for you.

sudo apt install needrestart

Running this program without options will attempt to restart all services that have been updated.

You can also run this program interactively if you want to see which services need to be restarted and choose only the one’s that you want to install.

sudo needrestart -r i

Finding services that need to be restarted in Centos 7 and RHEL 7

In Centos 7 and RHEL 7 the utility you need to check this should be installed by default. If not you can install the “yum-utils” package.

sudo yum -y install yum-utils

The command you will want to use is “needs-restarting” and will have to be run as root.

sudo sudo needs-restarting

sudo needs-restarting

This will again provide a list of services that need to be restarted.

OpenSUSE

When I originally posted this I neglected to mention OpenSUSE. Suse based distributions use a package manager called zypper, which as a side note is by far my favorite package manager. Anyway zypper natively has the ability to find services and processes that need to be restarted.

sudo zypper ps

Actually since Suse Enterprise Linux is one of my favorite flavors of Linux (I use it at least as much as Ubuntu if not more) I might do a blog early next week focused on package management with zypper.

Restart services manually

In all of the above cases if you are using a modern version of the distribution then you can restart services using systemctl

sudo systemctl restart <service>

If you are using an older version then you will need to run the service command.

sudo service <service> restart

Luke has an RHCSA for Red Hat Enterpirse Linux 7 and currently works as a Linux Systems Adminstrator in Ohio.

This post, re-published here with permission, was originally published on Luke’s site here.



Be the first to comment

Leave a Reply

Your email address will not be published.


*