Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #175294
| From | kushal@locationd.net |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Detect upgradable packages in shell script ran as a non-root user |
| Date | 2016-12-01 06:20 +0100 |
| Message-ID | <sJrWN-7OY-3@gated-at.bofh.it> (permalink) |
| References | <sJeGd-7Ih-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Martin T <m4rtntns@gmail.com> writes:
> Hi,
>
> I would like to run a cron job which periodically checks if I have
> upgradable packages. One way to do it is probably like this:
>
> $ apt-get upgrade -s | grep -q "^0 upgraded"
>
> In case exit code is >0, then there are upgradable packages. The
> second solution I came up with is:
>
> $ for package in $(dpkg-query -f '${binary:Package}\n' -W); do\
> apt-show-versions -u "$package" &>/dev/null && break;\
> done
>
> Again, if exit code is >0, then there is at least one upgradable
> package. Of course, a solution like "apt-show-versions | grep -q
> "upgradeable"" would also work.
>
> For me the "apt-get upgrade -s | grep -q "^0 upgraded"" seems to be
> the most reasonable solution, but maybe there is even a better way?
>
Does "apt list --upgradable" suit your needs?
Its output format is not stable and it produces a WARNING on stderr if
you use it in a pipe, which might disqualify it for cron usage, but I
use it when I'm check things by hand.
--
regards,
kushal
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Detect upgradable packages in shell script ran as a non-root user Martin T <m4rtntns@gmail.com> - 2016-11-30 16:10 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Greg Wooledge <wooledg@eeg.ccf.org> - 2016-11-30 16:20 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Shin Ice <shin.ice@shinice.net> - 2016-11-30 16:40 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Liam O'Toole <liam.p.otoole@gmail.com> - 2016-11-30 18:50 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Joe <joe@jretrading.com> - 2016-11-30 19:40 +0100
Re: Detect upgradable packages in shell script ran as a non-root user kushal@locationd.net - 2016-12-01 06:20 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Tixy <tixy@yxit.co.uk> - 2016-12-02 09:00 +0100
RE: Detect upgradable packages in shell script ran as a non-root user Bonno Bloksma <b.bloksma@tio.nl> - 2016-12-02 12:40 +0100
Re: Detect upgradable packages in shell script ran as a non-root user Jonathan Dowland <jmtd@debian.org> - 2016-12-02 12:50 +0100
csiph-web