« Linux : Redémarrage automatique des services après upgrade » : différence entre les versions
De www.yakakliker.org
 (Page créée avec « <syntaxhighlight lang="bash"> As others mentioned, the trouble in this case is with the needrestart command, which is part of the apt-get upgrade process in Ubuntu now (specifically 22.04 which is what I am using). 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, changing the line:  #$nrconf{restart} = 'i';  to  $nrconf{restart} = 'a'; (if we wa... »)  | 
				Aucun résumé des modifications  | 
				||
| Ligne 21 : | Ligne 21 : | ||
[[Catégorie:Linux]]  | [[Catégorie:Linux]]  | ||
<html>  | |||
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>  | |||
<script>  | |||
  kofiWidgetOverlay.draw('yakakliker', {  | |||
    'type': 'floating-chat',  | |||
    'floating-chat.donateButton.text': 'Café',  | |||
    'floating-chat.donateButton.background-color': '#00b9fe',  | |||
    'floating-chat.donateButton.text-color': '#fff'  | |||
  });  | |||
</script>  | |||
		</html>  | |||
Version du 21 janvier 2025 à 13:03
As others mentioned, the trouble in this case is with the needrestart command, which is part of the apt-get upgrade process in Ubuntu now (specifically 22.04 which is what I am using). 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, changing the line:
#$nrconf{restart} = 'i';
to
$nrconf{restart} = 'a'; (if we want to restart the services automatically) or $nrconf{restart} = 'l'; to simply list the services that need restart.
If you are running a script and want to make this edit without using an interactive editor like vim, you can do so using sed, something like:
sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
It looks ugly because of the single quotes in the config file and how sed handles single quotes, but it does work. Please leave a comment if you have a better looking approach.
Liens
https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services