Find services that require a restart

By: Luke Rawlins Dec 3, 2016 | 2 minutes read
Share this:

Tags: CentOS, Linux, Ubuntu

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.

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.

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

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.

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.

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

Related Posts


Change the Default Text Editor in Ubuntu

Change the Default Text Editor in Ubuntu So I’m a huge advocate of Ubuntu. It has long term support releases, more packages than you would ever need, free online unattended patching, and you always have an in-place upgrade path to the next LTS version. What more could you ask for? I’d like to ask that nano lose its privileged status as the default text editor! When making changes to sudoers, passwd, or group files you should really be using the built-in tools visudo, vipw, and vigr. Read more

Free SSL Certificate with Let’s Encrypt

Free SSL Certificate with Let’s Encrypt If you have ever installed an SSL certificate you know that it can be a tedious process. Let’s Encrypt makes this easy. Just call the letsencrypt command from the terminal and point it at your domain. Securing your website with a valid ssl certificate from a recognized and trusted vendor shows your website visitors that information transmitted between your site and their browser is encrypted. Read more

Bruh, do you even live patch?

Patching is arguably the single most important thing you can do to keep your systems secure. It’s also tedious, boring work that ends with everyone’s least favorite activity…. rebooting some indispensable, far too important for downtime server. Often meaning that patching takes a back seat to convenience, but no more! Starting with Ubuntu 16.04, and continuing on to the latest LTS Ubuntu 18.04 you can now update the kernel on a live system without a reboot. Read more


Contact

If you’d like to get in touch, contact with me via email - or follow on Twitter.

[email protected]