how to check in a script if updates are available
Ralf Mardorf
kde.lists at yahoo.com
Tue Mar 29 21:51:54 UTC 2022
On Tue, 29 Mar 2022 23:31:15 +0200, Ralf Mardorf wrote:
>On Tue, 29 Mar 2022 15:33:57 +0200, Oliver Grawert wrote:
>>> But how can i check in a script if updates are available ?
>>
>>you could likey craft something around "apt list --upgradeable"
>
>I second that. However, if you dislike to use apt in a script, since it
>warns that it should be used with caution in scripts, consider to use
>apt-get with a simulation/dry-run/assume-no option instead of using
>unattended-upgrades. Keep in mind that quite level 2 of apt-get assumes
>yes, hence don't use it.
PS:
FWIW "apt update" already mentions that upgrades are available, if
upgrades are available. Since you anyway first need to run "update",
you don't need to run something else, just to check if upgrades are
available. I don't know if you need to parse the output of apt or
apt-get, consider to test the exit status ($?), maybe it contains the
wanted information, too (I don't think so, but I would test it and/or
read the manual).
More information about the ubuntu-users
mailing list