How to manually restart services affected by apt upgrades?
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
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:
- Use
apt-get --download-only upgrade
to download updates in advance. - Hold specific packages back from upgrades.
- 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.
There is CLI based tool named as 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: