On my Ubuntu 20.04.2 LTS server i run my script with cron hourly. It's generate a text file. This file processed by conky on my desktop PC. In my script i use apt-check to know is there any update and if is how many is security. My problem is: apt-check and apt update totally different result. for example right now apt-check:
$(/usr/lib/update-notifier/apt-check)
17;1
same numbers which in motd message
however
apt update
apt upgrade
0 upgraded, 0 newly, 0 remove
why different output? how can i run apt to give me 2 numbers only like 17;1?
apt-check
queries the local package cache.apt update
queries the mirrors. If they have the same result, that's a coincidence of good timing since the mirrors get new updates constantly. For a list of security updates, see https://askubuntu.com/questions/774805/how-to-get-a-list-of-all-pending-security-updates; converting the list to a number (usingwc
) is left as an exercise for the student. – user535733 Aug 15 '21 at 12:06apt list --upgradable 2>&1 | wc -l | awk '{print $0-4}'
security upgrades:apt list --upgradable 2>&1 | grep "\-security" | wc -l
– Thomas Aug 17 '21 at 05:09