Centos – Find last time yum update was run

centosyum

Am building a script to find out when a list of servers was last fully updated with yum update.

I can find it by a history |grep "yum update"|head -n 1 however, the problem is that a user could have launced it but didn't type "y" in the prompt.

Another way I tried was with yum history

ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   109 | <xyz user>              | 2015-08-20 07:18 | Erase          |   1 E<
   108 | root <root>              | 2015-08-18 08:56 | Update         |    3 >
   107 | root <root>              | 2015-08-14 07:39 | Update         |    1
   106 | root <root>              | 2015-08-14 07:38 | Update         |    1
   105 | root <root>              | 2015-08-14 07:38 | Update         |    3
   104 | root <root>              | 2015-08-13 07:31 | Update         |    1
   103 | root <root>              | 2015-08-11 05:46 | Update         |    1
   102 | root <root>              | 2015-08-11 05:46 | Update         |    2
   101 | root <root>              | 2015-08-11 05:45 | Update         |    3
   100 | root <root>              | 2015-08-11 05:45 | Update         |    3
    99 | root <root>              | 2015-08-10 20:41 | Update         |    1
    98 | root <root>              | 2015-08-05 02:35 | Update         |    1
    97 | root <root>              | 2015-05-14 10:52 | Update         |    1
    96 | root <root>              | 2015-05-01 02:59 | Obsoleting     |    2
    95 | root <root>              | 2015-04-09 16:06 | Update         |    1  <
    94 | <xyz.user>            | 2015-03-28 08:49 | Update         |    1 ><
    93 | <xyz.usert>            | 2015-03-28 08:14 | Erase          |    3 ><
    92 | <xyz.user>            | 2015-03-13 07:46 | Install        |    6 ><
    91 | <xyz.user>             | 2015-03-13 05:45 | I, U           |   24 >
    90 | root <root>              | 2015-03-04 01:24 | Update         |    3

But I can't find a way of determining the date the yum update was launched and was successful. Since if I check, for example, the transaction ID 108 which is marked as "Update" launched on 18th, I don't find the command yum update for that particular date :

history |grep 2015 |grep "yum update"

 5182  20150313-054444 > yum update

Another path I tried was with /var/log/yum.log but yum.log will show installs and updates also. If a package is updated while installing a package e:g: yum install varnish and it requires an update of certain packages eg:(varnish-libs-2.1.5-5.el6.i686, 3.0.7-1.el6.i686 etc) this will be shown as updated in the yum.log

Is there a way to find the date a yum update was launched and it was successful?

Best Answer

You almost answered your question. Here is a way you can find latest 5 updated packages:

grep Updated: /var/log/yum.log | tail -5

Output example:

Aug 05 13:28:34 Updated: virt-manager-common-1.1.0-9.git310f6527.fc21.noarch
Aug 05 13:28:34 Updated: glusterfs-libs-3.5.5-2.fc21.i686
Aug 05 13:28:35 Updated: virt-manager-1.1.0-9.git310f6527.fc21.noarch
Aug 05 13:28:36 Updated: virt-install-1.1.0-9.git310f6527.fc21.noarch
Aug 05 13:28:38 Updated: glusterfs-3.5.5-2.fc21.i686
Related Question