7

How can I issue apt upgrades without automatically stopping/starting daemons? I'd like to manually restart services.

To cite a specific example:

I'll revisit a long-running machine and run sudo apt-get update && time sudo apt-get dist-upgrade. This is a very straight-forward means of seeing all available upgrades, followed by a simple Enter keypress to get the systems fully patched.

If I see postgresql-9.1 in the upgrade list, I abort the upgrade. In that case, apt would stop the service early in the process, apply several non-critical operations, then restart the service much later. A routine upgrade could cause minutes of downtime.

I'd like to say "yes" to the upgrade to get all patches applied, then manually restart the service at a convenient time.

rduplain
  • 5,788

3 Answers3

13

You can prevent service restarts with the Debian policy layer which works on Ubuntu as well.

Example: Create a file named /usr/sbin/policy-rc.d with following content (don't forget to make the file executable):

#!/bin/sh

exit 101

No service¹ would be automatically started/stopped/restarted anymore. See /usr/share/doc/sysv-rc/README.policy-rc.d.gz for details and how to adjust it to just ignore a single service.

1. as long as the installation scripts follow the Debian guidelines and use invoke-rc.d for service restarts

tlo
  • 521
3

I'd like to say "yes" to the upgrade to get all patches applied, then manually restart the service at a convenient time.

You can't do this in the general case, sorry. Even if a service is not restarted, packages don't provide any assurance that upgrades without service restarts won't break things (eg. anything dynamically loaded, like modules).

If you want a stable system, you should either hold back from upgrading a package, or upgrade it fully, complete with a service restart.

I can't really point to a credible source here, since I can't prove a negative. Debian policy is relevant here; it simply does not provide the guarantee that you are looking for. According to Debian policy, a package's functionality is not required to work until the postinst has finished successfully. So we can infer that if the postinst includes a mandatory service restart, then it needs to happen.

Some other mechanisms that might help you:

  1. Use apt-get --download-only upgrade to download updates in advance.
  2. Hold specific packages back from upgrades.
  3. Look into "high availability", so that servers can be upgraded in turn with no interruption to service. With Postgres, this would probably involve some kind of replicated configuration.
Robie Basak
  • 15,910
1

There is CLI based tool named as sysv-rc-conf Install sysv-rc-conf. You can also get it installed by running the following command in terminal:

sudo apt-get install sysv-rc-conf

Then you can activate/open it by running:

sudo sysv-rc-conf

Screenshot:

enter image description here

Raja G
  • 105,327
  • 107
  • 262
  • 331