yum history
これをたたくと、こんな結果が出力される。
(※sudo
が必要な人は付けてね!)
$ yum history
Loaded plugins: fastestmirror, versionlock
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
34 | <vagrant> | 2016-03-28 03:32 | Update | 13
33 | <vagrant> | 2016-03-28 02:29 | Install | 18
32 | <vagrant> | 2016-03-28 02:27 | Erase | 2
31 | <vagrant> | 2016-03-25 02:28 | Install | 1
30 | <vagrant> | 2016-03-18 08:14 | Install | 54
29 | <vagrant> | 2016-03-18 08:12 | Install | 5
28 | <vagrant> | 2016-03-16 07:27 | Install | 2
27 | <vagrant> | 2016-03-16 07:26 | Erase | 1
26 | <vagrant> | 2016-03-16 07:22 | Install | 1
25 | <vagrant> | 2016-03-07 07:56 | Install | 5
24 | <vagrant> | 2016-03-07 07:44 | Erase | 1
23 | <vagrant> | 2016-03-07 07:40 | Install | 1
22 | <vagrant> | 2016-03-07 07:33 | Erase | 1
21 | <vagrant> | 2016-03-07 03:55 | Install | 2
20 | <vagrant> | 2016-03-07 03:22 | Install | 1
19 | <vagrant> | 2016-03-07 02:49 | Install | 12
18 | <vagrant> | 2016-03-04 01:55 | I, U | 9 EE
17 | <vagrant> | 2016-03-03 02:41 | Install | 8
16 | <vagrant> | 2016-03-03 02:41 | Install | 3
15 | <vagrant> | 2016-03-03 02:40 | I, U | 3 EE
yum history info Transaction ID
Transaction ID
(上記の結果の1列目のID)を指定してたたくと、詳細情報が出力される。
(※sudo
が必要な人は…(ry )
$ yum history info 33
Loaded plugins: fastestmirror, versionlock
Transaction ID : 33
Begin time : Mon Mar 28 02:29:27 2016
Begin rpmdb : 414:8c0ce09d8e39aa61496e406e1f0be42b8117e8a7
End time : 02:30:02 2016 (35 seconds)
End rpmdb : 432:e62153a897c6c074c87068db8412e7634832d01b
User : <vagrant>
Return-Code : Success
Command Line : install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
Transaction performed with:
Installed rpm-4.8.0-47.el6.x86_64 @base
Installed yum-3.2.29-69.el6.centos.noarch @base
Installed yum-metadata-parser-1.1.2-16.el6.x86_64 @anaconda-CentOS-201311272149.x86_64/6.5
Installed yum-plugin-fastestmirror-1.1.30-30.el6.noarch @base
Installed yum-plugin-versionlock-1.1.30-30.el6.noarch @base
Packages Altered:
Dep-Install db4-cxx-4.7.25-20.el6_7.x86_64 @updates
Dep-Install db4-devel-4.7.25-20.el6_7.x86_64 @updates
Install expat-devel-2.0.1-11.el6_2.x86_64 @base
Dep-Install gdbm-devel-1.8.0-38.el6.x86_64 @base
Install gettext-devel-0.17-18.el6.x86_64 @base
Dep-Install gettext-libs-0.17-18.el6.x86_64 @base
Dep-Install libICE-1.0.6-1.el6.x86_64 @base
Dep-Install libSM-1.2.1-2.el6.x86_64 @base
Dep-Install libXtst-1.2.2-2.1.el6.x86_64 @base
Dep-Install libart_lgpl-2.3.20-5.1.el6.x86_64 @base
Install libcurl-devel-7.19.7-46.el6.x86_64 @base
Dep-Install libgcj-4.4.7-16.el6.x86_64 @base
Dep-Install libidn-devel-1.18-2.el6.x86_64 @base
Install perl-ExtUtils-MakeMaker-6.55-141.el6_7.1.x86_64 @updates
Dep-Install perl-ExtUtils-ParseXS-1:2.2003.0-141.el6_7.1.x86_64 @updates
Dep-Install perl-Test-Harness-3.17-141.el6_7.1.x86_64 @updates
Dep-Install perl-devel-4:5.10.1-141.el6_7.1.x86_64 @updates
Dep-Install zip-3.0-1.el6_7.1.x86_64 @updates
history info
同じ日付で複数回yum
でインストールしたり削除したりする可能性も大いにある。これを一括で表示するようにしたい。
上記の2016-03-28
の場合だとID=32, 33, 34が対象となるので、yum hisotory info 32..34
と指定してたたくと、まとめて表示される。しかし、このままだとコマンド一発では対象のIDを指定できないので、2回コマンドをたたく必要がある。
ワンライナー
これを一発で決めたものがこちら。
(※sudo
が…(ry )
$ yum history | grep -i '日付' | awk '{print $1}' | yum history info $(tail -n 1)..last
上記の日付
を指定すれば、調べたい日のyum historyの詳細情報が取れる。
個人的にポイントと思ったのは、最後の$(tail -n 1)
とlast
を使うところかな。日付を指定してTransaction ID
を取得し、それの最初と最後が取れれば勝ちだった。
追記
上記だと、指定した日付の一番古いIDから最新のIDまでの全てを取得してしまい、指定した日付から最新までの全ての情報を取得してしまっていたので、直した。どんな修正をしたのかを残すため、消さずにおいておく。
$ vtail=$(yum history | grep -i '日付' | awk '{print $1}' | tail -n 1) && vhead=$(yum history | grep -i '日付' | awk '{print $1}' | head -n 1) && yum history info ${vtail}'..'${vhead}
無理やりになってしまい悔しいが、現状(2016/03/28時点)では上手い方法が見つからなかった…指定した日付の最初と最後のIDを一つずつ取ってきて変数vtail, vhead
に格納し、最後にそれらを使って情報を取得。また使う機会があると思うけん、そのとき改めて考える。
以上!
PS
※もっと上手い方法があれば、是非是非ご教授願います。