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?


thanks,
Martin

Reply via email to