« 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 |
||
(Une version intermédiaire par le même utilisateur non affichée) | |||
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> | |||
<html> | |||
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a> | |||
</html> |
Dernière version du 17 février 2025 à 17:56
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