Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Check disk space used by Portage
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
fatcat.00
Tux's lil' helper
Tux's lil' helper


Joined: 12 Aug 2002
Posts: 145

PostPosted: Sun Jun 08, 2003 2:25 pm    Post subject: Check disk space used by Portage Reply with quote

Here is a really simple script that checks various directories used by portage for temp files, source etc. There might be something like this already in gentools collection, but if there is I don't know about it.

I added this to a cron job so I am periodically notified via email how big things are getting. I have run out of disk space a couple times, but now this keeps that from happening. :)

Code:
#!/bin/bash
# -----------------------------------------------------------------------------
# PROGRAM: usedbyportage.sh
#        : A simple script to check the size of certain
#        : directories commonly used by portage.
# -----------------------------------------------------------------------------
# LICENSE: Released by the author to the Public Domain
# -----------------------------------------------------------------------------
# USAGE  : usedbyportage.sh [depth]
#        : where [depth] corresponds to the depth you want to look
#        : into the given directory structure.  Default is 0, but a
#        : depth of 1 is useful too.

# Add whatever directories you want to check here
CHK_DIRS="/usr/portage/distfiles /var/cache/edb /var/tmp/portage"

WHITE=$'\e[1;37m'
GRAY=$'\e[0;37m'
GREEN=$'\e[1;32m'
YELLOW='\e[1;33m'
BLUE=$'\e[1;34m'
MAGENTA=$'\e[1;35m'
CYAN=$'\e[1;36m'

# If running as non-root, you will get errors when checking certain
# directories.  STDERR is being dumped to the bitbucket, so you won't
# see the errors.  Remove the "2>&1" if you want to see errors in the
# output.
for dir in $CHK_DIRS ; do
    echo "$WHITE*** CHECKING$CYAN $dir $WHITE***$GRAY"
    if [ -z "$1" ] ; then
        du --max-depth=0 $dir 2>&1 | grep ^[0-9] | sort -g
    else
        du --max-depth=$1 $dir 2>&1 | grep ^[0-9] | sort -g
    fi
done

_________________
-- Fatcat
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum