Clean up Spacewalk/Satellite/SUSE Manager software channels
After some time old packages are accumulated in software channels managed by Spacewalk, Red Hat Satellite or SUSE Manager.
Especially at least when your hard drive are threaten to get tanked up you should clean up and remove unneeded packages. For this there is a utility called spacewalk-data-fsck
- but this tool only removes packages from the hard drive that cannot be found in the database.
In the Red Hat Spacewalk mailing list I found a script developed by Nicolas Pradelles that removes old package versions. This script scans all software channels and removes outdated packages from the database and the file system.
The script can be downloaded without any charge - but you have to customize it because you need to provide server, user name and password information:
1# wget -O packages_cleanup.sh https://www.redhat.com/archives/spacewalk-list/2012-April/bin1dA64IopcS.bin
2# vi packages_cleanup.sh
3...
4LOGIN='username'
5PASS='password'
6SRV='localhost'
After altering the script is ready - cleaning a servers looks like this:
1# ./packages_cleanup.sh
2
3################
4centos6-updates-x86_64
5################
6389-ds-base-1.2.11.15-14.el6_4.x86_64
7389-ds-base-1.2.11.15-20.el6_4.x86_64
8389-ds-base-1.2.11.15-22.el6_4.x86_64
9...
10xulrunner-devel-17.0.9-1.el6.centos.i686
11xulrunner-devel-17.0.9-1.el6.centos.x86_64
12centos6-updates-x86_64: ALL=1538, LATEST=825, OLD=714, DELETED=705
13...
14Removed file missing in db: /var/satellite/redhat/...
You can easily automate this in a weekly cronjob:
1# mkdir /opt/tools; mv packages_cleanup.sh /opt/tools
2# vi /etc/cron.weekly/spacewalk_clean.cron
3#!/bin/sh
4MAILTO=root
5
6#remove older versions of packages
7/opt/tools/packages_cleanup.sh
8
9ESC ZZ
10
11# chmod 755 /etc/cron.weekly/spacewalk_clean.cron
Thanks to this you don't need to clean up the server manually - which means more time for more senseful things in an Administrator's everyday life (e.g. cooking and drinking coffee). 😉