some blag

November 5, 2008

pacman’s cache strikes again

Filed under: Uncategorized — andrew @ 10:05 pm

~/.config/fsniper/scripts/pacman-cache.sh


#!/bin/bash
# This script checks the pacman cache directory and runs a command if it is over a certain size.
MAXSIZE="3500" # run the command you if the cache is over this size (in mb)
# run this command if CACHE is > MAXSIZE
COMMAND="echo \"oh no pacman's cache is over $MAXSIZE\" | mail -s \"pacman warning\" me@gmail.com "
CACHE="/var/cache/pacman/pkg" # cache location

if [[ "`du -sm $CACHE`" > "$MAXSIZE" ]]; then
$COMMAND
fi

and in ~/.config/fsniper/config

/var/cache/pacman/pkg/ {
* {
handler = pacman-cache.sh %%
}

2 Comments »

  1. You could make this more generic by passing %d in the fsniper handler and a size there too. Then adjust your script to handle those instead of hardcoding your values.

    Comment by Dave Foster — November 6, 2008 @ 8:10 am

  2. @Dave Foster
    true, if I ever have another directory like that that fills up /var :|

    Comment by andrewy — November 6, 2008 @ 9:49 am

RSS feed for comments on this post.

Leave a comment

Powered by WordPress