Thanks Re: [K12OSN] scripting trash removal

Mark Gumprecht gumprechtm at msad3.org
Thu Mar 30 14:04:40 UTC 2006


Thanks to all who helped me get this.

Cache removal

#!/bin/bash
for x in `ls /home`; do
echo "Doing $x ..."
find /home/${x}/.mozilla/firefox/*.default/Cache/* -exec rm -Rf {} \;
done


Trash removal older than 7 days

#!/bin/bash
for x in `ls /home`; do
echo "Doing $x ..."
find /home/${x}/.Trash -atime +7 -exec rm -f {} \;
done


Mark


Petre Scheie wrote:

>
>
> Mike Ely wrote:
>
>> Toshio Kuratomi wrote:
>>
>>> On Fri, 2006-01-27 at 13:22 -0500, Mark Gumprecht wrote:
>>>
>>>> Dave was nice to send me this for clearing cache
>>>>
>>>> !#/bin/bash
>>>> for x in `ls /home`; do
>>>> echo "Doing $x ..."
>>>> cd /home/${x}/.mozilla/firefox/*.default/Cache
>>>> rm -Rf *
>>>> done
>>>>
>>>> Ok that works just fine. Soooo, If that works for cache, with a 
>>>> little mod like this
>>>>
>>>> !#/bin/bash
>>>> for x in `ls /home`; do
>>>> echo "Doing $x ..."
>>>> cd /home/${x}/.Trash
>>>> rm -Rf *
>>>> done
>>>
>>>
>>>
>>> You've probably already considered this but just in case:
>>>
>>> Deleting cache files should be relatively transparent to an end-user 
>>> (It
>>> affects their performance somewhat but they shouldn't lose data.)
>>> Deleting the contents on .Trash is unexpectedly circumventing the way
>>> the Trash works (to be able to recover deleted files.)
>>>
>>> If you hadn't already considered that, you might want to implement 
>>> aging
>>> of the Trash (like the tmpwatch program for /tmp) or user quotas (so 
>>> the
>>> user has to empty the Trash themselves in order to stay under quota.)
>>>
>>> -Toshio
>>
>>
>>
>> That's a good point.  However, the vast majority of users do not use 
>> their Trash (or Recycle Bin) correctly at all.  I'm sure many in here 
>> can recount numerous times where they found a user with a couple of 
>> gigs of general rubbish in their trash.  Most people delete stuff and 
>> never ever empty.  Yeah, there was that one lady who freaked when I 
>> emptied her trash (it's almost a nervous habit for me when sitting 
>> down at a desktop).  Apparently she was actually using it as a folder 
>> to store stuff.  D'oh!
>>
>> Mike
>>
> Taking the above into consideration, how about this:
>
> !#/bin/bash
> for x in `ls /home`; do
> echo "Doing $x ..."
> find /home/${x}/.Trash -atime +30 -exec rm -f {}\;
> done
>
> This will search each user's ~/.Trash directory for files that have 
> not been accessed for at least 30 days and delete any it finds.  If a 
> user has no .Trash directory, it just spits out an error.   If you 
> want to test it just to make sure it's going to remove the correct 
> files, replace the 'rm -f' part with, say, 'ls -l' and it will just 
> display the files.  Once you're sure it will pick the correct files, 
> change back to 'rm -f'.
>
> Petre
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>

-- 
Mark Gumprecht
Data Systems Specialist
MSAD3
Unity, ME
gumprechtm at msad3.org




More information about the K12OSN mailing list