RPM

From Unix Wiki
Jump to: navigation, search

List all packages by install date

rpm -qa --queryformat '%{installtime} (%{installtime:date}) %{name}-%{version}-%{arch}\n' | sort -rn

List non-RHEL/OEL packages

This script queries and writes to files information about non-RHEL/OEL packages on servers from Server List. Of course users must have passwordless ssh access to target servers.

#!/bin/bash
srv_list=$1   #Server list path (as argument to script)
for server in `cat $srv_list`; do
 echo "------------- Checking $server server -------------"
 ping -c1 -w5 $server &> /dev/null
 if [ $? -ne 0 ]; then
   echo "$server not pingable"
   continue
 fi
 ssh topaz@$server "rpm -qa --qf '%{NAME}-%{VERSION}.%{ARCH} %{VENDOR}\n'|grep -vi -e \"red hat\" -e \"Oracle USA\" -e \"Oracle America\" -e \"gpg-pubkey\"|sort"|unix2dos > ${server}.txt
done