Sort RPMs by install time

From time to time, I have needed to list the RPMs installed on a Linux system sorted in install-time order. This (for example) allows you to see which RPMs where most recently added.

This is easily done using the following command..

rpm -qa --qf '%{INSTALLTIME} %{NAME}-%{RELEASE}-%{VERSION}\n' | sort -n

This gives an output looking like this, for example..

1397746004 perl-IO-Compress-Base-136.el6-2.021
1397746004 perl-IO-Compress-Zlib-136.el6-2.021
1397746004 perl-IO-stringy-10.1.el6-2.110
1397746004 perl-libwww-perl-2.el6-5.833
1397746004 perl-TimeDate-11.1.el6-1.16
1397746005 perl-MailTools-4.el6-2.04
1397746005 perl-MIME-Lite-2.el6-3.027
1397746005 perl-SOAP-Lite-3.el6-0.710.10
1397746006 perl-MIME-tools-4.el6-5.427
1407338985 apache_synapse-4065-2.0.0
1407339005 apache_activemq-4065-5.4.3

The first column is the install time, expressed as the number of seconds since 1st Jan 1970. The second column is the name, release and version of the package. The list is sorted to show the most recently install RPMs at the end.

If you want a listing of all the field names that can be used via the "%{xxxx}" syntax in the shell command above, then try this..

rpm --querytags

The resulting listing looks like this..

ARCH
ARCHIVESIZE
BASENAMES
BUGURL
BUILDARCHS
BUILDHOST
BUILDTIME
C
CAPABILITY
CHANGELOGNAME
CHANGELOGTEXT
CHANGELOGTIME
CLASSDICT
CONFLICTFLAGS
CONFLICTNAME

.. etc

If you want to add the architecture to the listing, then the field "ARCH" seems like a good bet. So you could adjust your original command like this to add it, in brackets, to the end of each line..

rpm -qa --qf '%{INSTALLTIME} %{NAME}-%{RELEASE}-%{VERSION} (%{ARCH})\n' | sort -n

Giving..

1397746004 perl-IO-Compress-Base-136.el6-2.021 (x86_64)
1397746004 perl-IO-Compress-Zlib-136.el6-2.021 (x86_64)
1397746004 perl-IO-stringy-10.1.el6-2.110 (noarch)
1397746004 perl-libwww-perl-2.el6-5.833 (noarch)
1397746004 perl-TimeDate-11.1.el6-1.16 (noarch)
1397746005 perl-MailTools-4.el6-2.04 (noarch)
1397746005 perl-MIME-Lite-2.el6-3.027 (noarch)
1397746005 perl-SOAP-Lite-3.el6-0.710.10 (noarch)
1397746006 perl-MIME-tools-4.el6-5.427 (noarch)
1407338985 apache_synapse-4065-2.0.0 (x86_64)
1407339005 apache_activemq-4065-5.4.3 (x86_64)
1407340771 jdk-fcs-1.7.0_45 (x86_64)
Scroll to Top