Ubuntu 22 Apt Auto-Restart Services
The trouble is with the needrestart
command, which is part of the apt-get upgrade process in Ubuntu now (specifically 22.04). By default, this is set to "interactive" mode, which causes the interruption of scripts.
To change this behavior, we can edit the /etc/needrestart/needrestart.conf
file
sudo nano /etc/needrestart/needrestart.conf
Change the line:
#$nrconf{restart} = 'i';
to
$nrconf{restart} = 'a';