#!/bin/sh # # cleangridmapdir - Clean up the gridmapdir and home directories of pool # usernames. # If this script is placed in /etc/cron.hourly on Linux, # then expired associations will be cleaned out every hour. # # http://www.hep.grid.ac.uk/gridmapdir/ # # Andrew McNab March 2001 # homedirs=/home/gpool # where the home directories are made group=users # group used by pool users expiremin=1440 # length of lease in minutes (1440m=24h) ########## You dont need to edit anything below this line ######### ########## but you should make sure you understand it before ######### ########## running this script on your system !!!!!!!!!!!!!! ######### PATH=/usr/bin:/bin export PATH cd /etc/grid-security/gridmapdir # first clean the directories find . ! -name '%*' -type f -links 2 -cmin +$expiremin | cut -f2 -d/ | ( while read username do rm -Rf "$homedirs/$username" mkdir -p "$homedirs/$username" chown $username.$group "$homedirs/$username" chmod 0700 "$homedirs/$username" echo Cleaned up and reset directory "$homedirs/$username" done ) > /var/log/cleanpool.log 2>&1 # then the expired leases (yes, we should really do some kind of locking...) find . -name '%*' -type f -cmin +$expiremin -exec rm -f {} \; \ >>/var/log/cleanpool.log 2>&1 #