[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Finding unused packages



On Fri, Apr 19, 2002 at 12:59:52PM -0400, Mike Dresser wrote:
> On 19 Apr 2002, Peter Whysall wrote:
> 
> > > find / -type f -atime +30 -perm +111 | xargs dpkg -S | sort | uniq >
> > > old.txt
> >
> > Well, old.txt now contains the following:
> >
> > peter:~ $ more old.txt
> > fdflush: /bin/fdflush
> >
> > Hmm. I wonder if that hasn't taken it from one extreme to the other...
> 
> Odd.  Even if i crank it up to 120 days, I still gets dozens of files
> reported.
> 
> > Will the nightly running of updatedb throw a spanner in the works?
> 
> Well, I run updatedb now and then and it still gives me lots of files.
> 
> Mike

This approach suffers from at least 3 problems: 

-   It will report the package names where *some* file has not been used
    for XX days.  Which is different from packages where *all* files
    have not been used for XX days... You don't want to deem a package
    unused only because one or 2 files haven't been used...

-   Some backup schemes will modify the atime on files

-   Some people (especially laptop users it seems) like mounting /usr
    with the "noatime" option, which stops the recording of atimes
    alltogether...

If we ignore the two latter problems, then what about something like
this script: (seems to work for me, but probably has some bugs in it.
GPLv2. No warranty etc):

#!/bin/sh

NUMDAYS=30

deborphan -a | awk '{print $2; }' | sort -u |
while read package
do
    printf "Examining $package ... "

    dpkg --listfiles $package | while read file
    do
        [ -f $file ] && echo $file
    done > /tmp/this-package

    if [ $(xargs < /tmp/this-package --no-run-if-empty --replace=SADDAM \
            find SADDAM -atime -${NUMDAYS} -print | wc -l) -gt 0 ]
    then
        echo Used recently.
    else
        echo Has not been used for ${NUMDAYS} or more...
    fi
done

??
-- 
Karl E. Jørgensen
karl@jorgensen.com
www.karl.jorgensen.com
==== Today's fortune:
It seems intuitively obvious to me, which means that it might be wrong.
		-- Chris Torek

Attachment: pgpEeTy20myWA.pgp
Description: PGP signature


Reply to: