To keep track of it I generate a list of packages installed and orphans packages every day.
# m h dom mon dow command
00 02 * * * /usr/bin/updatedb
00 11 * * * /usr/bin/dpkg --get-selections > /root/debian-packages/`date +\%Y-\%m-\%d`-packages.list; SUFFIX=packages.list /root/debian-packages/deleteEquals.sh
01 11 * * * /usr/bin/deborphan > /root/debian-packages/`date +\%Y-\%m-\%d`-deborphan; SUFFIX=deborphan /root/debian-packages/deleteEquals.sh
Also, to don't waste space, I created a small script to remove the lists in case they don't have any changes, which is the "deleteEquals.sh" script.
The script just need the variable SUFFIX set so it knows which files should be checked, the whole script is below:
#!/bin/bash
SUFFIX=${SUFFIX:="packages.list"}
cd /root/debian-packages
for i in $(ls -1rt /root/debian-packages/*${SUFFIX}); do
if [ -z $PREVIOUS ]; then
PREVIOUS="$i";
else
diff -q $PREVIOUS $i > /dev/null 2>/dev/null;
RESULT="$?";
if [ $RESULT -eq 0 ]; then
rm $PREVIOUS;
fi
PREVIOUS="$i";
fi;
done
No comments:
Post a Comment