8

With unattended-upgrades duly set up to automatically do upgrades, reboots and all, I'm stumped to find output like this in its daily report sometimes:

...
Restarting services...
 /etc/needrestart/restart.d/systemd-manager
 systemctl restart accounts-daemon.service networkd-dispatcher.service polkit.service systemd-networkd.service systemd-resolved.service systemd-timesyncd.service systemd-udevd.service

Service restarts being deferred
 systemctl restart apt-daily-upgrade.service
 systemctl restart systemd-journald.service
 systemctl restart systemd-logind.service
 systemctl restart unattended-upgrades.service
...

I understand this is output from needrestart. I do not understand what sets the services that do get restarted apart from the ones that don't. What configuration do I need to change to make it restart all these services unattendedly?

cueedee
  • 215
  • 1
  • 8

1 Answers1

7

The needrestart package maintains an exclusion list of services that should not be restarted automatically in /etc/needrestart/needrestart.conf. Look for the $nrconf{override_rc} setting.

Be careful modifying this list. Based on my quick glance, it seems like most of these default exclusions are due to user reported issues that arise when restarting services. A lot of the exclusions in that file have a comment with a Debian bug tracker number that explains why the exclusion is there.

Looking at the example in your question, these exclusions are causing your services to not be restarted automatically:

  • apt-daily-upgrade.service and unattended-upgrades.service aren't restarted because restarting those can kill the running needrestart process if it was started by those services. This is documented in bug #862840.
  • systemd-journald.service isn't being restarted because it breaks a lot of other services. This is documented in bug #771122. However, this question is 2 years old and this exclusion isn't present in newer versions (3.4+) of needrestart. It's not excluded on my Ubuntu 22.04 system.
  • systemd-logind.service isn't restarted because doing so kills your running X server session. This is documented in bug #798097.
BrokenBinary
  • 188
  • 1
  • 6