On Thu, Apr 10, 2008 at 09:28:33PM +0200, bgs wrote:
> Well... don't fight! :)
> Here a simple cleanup script you can put in your crontab.
> I write my scripts in zsh but skimming through this, it should work as is
> with bash too (if you don't have zsh).
>
>
>
> #!/bin/zsh
>
> DEFAGE=7
> #DEBUG=1
>
> usage()
> {
> echo -e "clear-graylist {max_age_in_days}\n\tDefault age is ${DEFAGE}"
> exit 1
> }
>
> CONF=/etc/spamdyke.conf
> AGE=${${1}:-${DEFAGE}}
>
> graylist_base=$(grep "^graylist-dir=" ${CONF}|head -1)
> graylist_base=${graylist_base##graylist-dir=}
>
> [[ ! -z ${DEBUG} ]] && echo "debug: AGE=${AGE}
> graylist_base=${graylist_base}"
>
> find ${graylist_base}/ -type f -ctime +2 | xargs rm
Some minor nitpicking:
I don't know if spamdyke will allow addresses with special characters or
spaces in them, but if yes, the above script will not do what's expected.
The last line should read
find "${graylist_base}/" -type f -ctime +2 -print0 | xargs -0 rm
or, if you have a recent version of findutils:
find "${graylist_base}/" -type f -ctime +2 -exec rm {} +
Also, shouldn't you be removing unneeded recipient directories too? In zsh,
the following should do it:
rmdir "${graylist_base}"/*/*(/) # will print errors for non-empty directories
You could do something more sophisticated based on find(1).
Andras
--
Andras Korn <korn at chardonnay.math.bme.hu>
<http://chardonnay.math.bme.hu/~korn/> QOTD:
Computer Lie #1: You'll never use all that disk space.
_______________________________________________
spamdyke-users mailing list
[email protected]
http://www.spamdyke.org/mailman/listinfo/spamdyke-users