Score:1

apt-check vs apt update different result

cn flag

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?

user535733 avatar
cn flag
`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 (using `wc`) is left as an exercise for the student.
Thomas avatar
cn flag
Thank you for your help. my solution is: upgradable packages: `apt list --upgradable 2>&1 | wc -l | awk '{print $0-4}'` security upgrades: `apt list --upgradable 2>&1 | grep "\-security" | wc -l`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.