我正在运行12.04 LTS ubuntu服务器。而且我认为如果能够在更新可用时得到通知会很好。但我找不到方法
我尝试查看apt-get
手册页。从中我可以用来apt-get -s upgrade
在脚本中获取apt-get输出,而不会阻塞问题。
现在,我清楚地看到了区别:
有可用的更新:
apt-get -s upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
dpkg dpkg-dev libdpkg-perl
3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Inst dpkg [1.16.1.2ubuntu7.2] (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [amd64])
Conf dpkg (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [amd64])
Inst dpkg-dev [1.16.1.2ubuntu7.2] (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [all]) []
Inst libdpkg-perl [1.16.1.2ubuntu7.2] (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [all])
Conf libdpkg-perl (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [all])
Conf dpkg-dev (1.16.1.2ubuntu7.3 Ubuntu:12.04/precise-updates [all])
更新不可用:
apt-get -s upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
但是我不知道如何从那里继续。我如何通过bash脚本(或php脚本)判断是否有可用的更新?
编辑:
这是我当前的bash代码。这没用。
updates_available=`/etc/update-motd.d/90-updates-available`
if [ "${updates_available}" = "0 packages can be updated. 0 updates are security updates." ];
then
echo "No updates are available"
else
echo "There are updates available"
fi
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
是否没有更新。