[K12OSN] Help with script

Burroughs, Henry HBurroughs at hhprep.org
Tue May 12 19:36:01 UTC 2009


Brian,

See code below... put in .sh script and run through cron (test please as
I haven't used this in a while!) Example Use:

clear-browsercache.sh /home 25

That should cycle through all the users under /home.... in our case, I
would run: clear-browsercache.sh /home/students 25 because students are
in a subdir.....

----------------Code below:-------------

#!/bin/bash

# Copyright Henry Burroughs
 
#       This program is free software; you can redistribute it and/or
modify
#    it under the terms of the GNU General Public License as published
by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
 
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
 
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307  USA


# This script clears the browser cache files for user directories under
the following directories:
# It takes 2 parameters:
#   <home> - The directory that holds the user homedirectories
#   <mtime> - Purge Cache files older than <mtime> days

# This finds all Mozilla/Firefox Cache files that are older than 30
days:
#find . -path "./*/.mozilla/*/*/Cache/*" -type f -mtime +30 -print

if [ $# -lt 2 ]; then
	echo "$0 <home> <mtime>"
	echo ""
	echo -e "\t<home> - The Directory that holds the user home
directories"
	echo -e "\t<mtime> - Purge cache files older than <mtime> days"
	echo "Example:"
	echo -e "\t$0 /home 10"
	echo -e "\tWill purge mozilla & firefox cache files older than
10 days"
	exit
fi

cd $1
find . -path "./*/.mozilla/*/*/Cache/*" -type f -mtime +$2 -exec rm -f
{} \;


-----END CODE-------------------------------------------
Henry Burroughs
Technology Director
Hilton Head Preparatory School
www.hhprep.org


Message: 15
Date: Wed, 29 Apr 2009 15:32:28 +0100
From: Brian Chivers <brian at portsmouth-college.ac.uk>
Subject: [K12OSN] Help with script
To: "Support list for opensource software in schools."
	<k12osn at redhat.com>
Message-ID: <49F864FC.9070508 at portsmouth-college.ac.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I'm trying to use the script on the k12ltsp wiki(1) to remove firefox
cache but the problem is that 
our students directories are in sub directories under /home_student e.g

/home_student
	tutorgroup
		2S-EG
		   k123456

How can I alter the script to descend into each if the sub directories
and wipe as it goes ??

Thanks
Brian Chivers
Portsmouth College

(1)http://k12ltsp.org/mediawiki/index.php/Cache_Removal

------------------------------------------------------------------------
------------------------
    The views expressed here are my own and not necessarily
 
                the views of Portsmouth College    



------------------------------




More information about the K12OSN mailing list