Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want my cron-run reporting script to notify me in case there are updates for my packages. Is the a way to make apt-get give me the list of available updates but don't do anything more?

share|improve this question
add comment

6 Answers

The -u switch shows a list of packages that are available for upgrade:

# apt-get -u upgrade

From the apt-get man page:

-u
--show-upgraded
 Show upgraded packages; Print out a list of all packages that are to be upgraded. Configuration Item: APT::Get::Show-Upgraded.
share|improve this answer
2  
apt-get -u upgrade --assume-no if you don't want it to ask if you want them installed. Does this on 12.10. –  slm Dec 17 '13 at 3:47
add comment

Take a look at package "apticron":

apticron - Simple tool to mail about pending package updates

http://packages.debian.org/squeeze/apticron

share|improve this answer
add comment

You can run

aptitude -F%p --disable-columns search ~U

or the undocumented

/usr/lib/update-notifier/apt-check -p; echo

Another method using an apt-get simulation:

apt-get -s dist-upgrade | awk '/^Inst/ { print $2 }'
share|improve this answer
add comment
apt-get --just-print upgrade

Is not read that easily, below is a perl one liner to parse apt-get's output:

apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "PROGRAM: $1 INSTALLED: $2 AVAILABLE: $3\n"}'

This should output something like:

PROGRAM: grub-pc INSTALLED: 1.99-21ubuntu3.1 AVAILABLE: 1.99-21ubuntu3.9

Hopefully it will help someone else,

share|improve this answer
1  
just for the laugh: apt-get -s upgrade| awk -F'[][() ]+' '/^Inst/{printf "Prog: %s\tcur: %s\tavail: %s\n", $2,$3,$4}' –  tink May 17 '13 at 3:19
add comment
apt-get update && apt-get -s upgrade

will list available updates without actually installing.

First command updates package index files before simulated (thus -s) upgrade is done. "-s" will do a simulated upgrade showing packets that would be installed but will not actually install anything.

On the contrary "-u" instead of "-s" would actually install after confirmation.

share|improve this answer
add comment

Another option, inspired by enzotib :

aptitude search '~U' | wc -l

This command will use aptitude to output the new packages and then wc to just count the lines.

On a sidenote, I found that enzotib's solution without the single quotes around the ~U didn't work for me. (Wheezy, ZSH, aptitude 0.6.8.2)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.