Restart system services after an OS update

This guide describes how to use the clr-service-restart tool.

Overview

Clear Linux* OS includes a clr-service-restart tool that shows which system daemons require a restart.

clr-service-restart reads various files in the procfs filesystem provided by the kernel and relies on systemd to determine which services to restart.

How it works

clr-service-restart implements a whitelist to identify which daemons can be restarted. As a system administrator, you can customize the default Clear Linux OS OS whitelist using allow or disallow options for restarting system services. When a software update occurs, clr-service-restart consults the whitelist to see if a service daemon is allowed to be restarted or not.

Basic options

clr-service-restart has three basic options: allow, disallow, and default.

allow

The allow option identifies a daemon to restart after an OS software update. The clr-service-restart daemon creates a symlink in /etc/clr-service-restart as a record. The example below tells clr-service-restart to restart the tallow daemon after an OS software update.

sudo clr-service-restart allow tallow.service

disallow

The disallow option tells clr-service-restart not to restart the specified daemon even if the OS defaults permit the daemon to be restarted. The clr-service-restart daemon creates a symlink in /etc/clr-service-restart that points to /dev/null as a record. The example below tells clr-service-restart not to restart the rngd daemon after an OS software update.

sudo clr-service-restart disallow rngd

default

The default option makes clr-service-restart revert back to the OS defaults and delete any symlink in /etc/clr-service-restart. The example below tells clr-service-restart to restart rngd automatically again, because rngd is whitelisted for automatic service restarts by default in Clear Linux OS.

sudo clr-service-restart default rngd

Monitor options

clr-service-restart works in the background and is invoked with swupd automatically. Review the journal output to verify that services are restarted after an OS software update.

If you pass both options (-a and -n) described below, clr-service-restart displays a complete list of system services that require a restart. Use both options to verify that all desired daemons are restarted.

-n option

The -n option makes clr-service-restart perform no restarts. Instead it displays the services that could potentially be restarted. When used, clr-service-restart outputs a list of messages showing:

  • Which service needs a restart.
  • What unit it is.
  • Why it needs a restart.
  • Which command is required to restart the unit.

-a option

The -a option makes clr-service-restart consider all system services, not only the ones that are whitelisted. Because the default whitelist in Clear Linux OS is relatively short, you can use this option to restart all impacted services when you log in on the system.

Example

In the example below, clr-service-restart is invoked with both the -a and -n options, which displays a complete list of system services that require a restart.

Command:

sudo clr-service-restart -a -n

Sample output:

upower.service: needs a restart (a library dependency was updated)
/usr/bin/systemctl --no-ask-password try-restart upower.service
NetworkManager.service: needs a restart (a library dependency was
updated)
/usr/bin/systemctl --no-ask-password try-restart NetworkManager.service
....

Telemetry

clr-service-restart may cause problems such as a short service outage when a daemon is being restarted, or if a daemon fails to properly restart. To minimize issues, clr-service-restart creates a telemetry record and sends it to the optional Clear Linux OS telemetry service if both conditions below are met:

  • If a unit fails to automatically restart after an OS update.
  • If that unit resides in the system location /usr/lib/systemd/system.

If you do not install the Clear Linux OS telemetrics bundle, the data is discarded. If you install the telemetrics bundle and you opt to send telemetry, then the system unit name is sent to the Clear Linux OS telemetry service. We evaluate the report and update the whitelist to remove services that are not safe to restart.

Conclusion

The Clear Linux OS team enjoys coming up with simple and efficient solutions to make your work easier. We made a GitHub* project of clr-service-restart and we invite you to look at the code, share your thoughts, and work with us on improving the project. You can find the project at:

https://github.com/clearlinux/clr-service-restart