Re: Are "Caches" directories safe to delete?



ZnU <znu@xxxxxxxxxxxx> wrote:
> Wandering No Mad <wanderingnomad@xxxxxxxxx> wrote:
>
> > Is it safe to delete the contents of my system's Caches directories?
> > I was thinking of logging into the console and doing this, without the
> > WindowServer running:
> >
> > $ sudo rm -rf ~/Library/Caches/*
> > $ sudo rm -rf /Library/Caches/*
> > $ sudo rm -rf /System/Library/Caches/*
> >
> > Is there any danger in doing this? I'm a little nervous about touching
> > anything in /System, even cache files. But I think of anything labeled
> > as "Cache" as "something indexed or stored for convenience, but which
> > can be regenerated as needed", and therefore safe to delete. In the
> > course of trying to diagnose system problems, this might be a useful
> > step, but not if I'm going to make my system inoperative.
>
> Cache files are, as you surmised, safe to delete. Even system cache
> files.

Let everyone know if it causes any problems. I made mine selective.

# The periodic and atrun jobs have moved to launchd jobs
# See /System/Library/LaunchDaemons
#
# minute hour mday month wday who command
0 0,4,8,12,16,20 * * * root /Users/root/bin/Cache_cleanups.sh


cat /Users/root/bin/Cache_cleanups.sh
#!/bin/sh

body() {

cd /Users/root/Library/Caches || { echo "Can't make current the Cache
directory!"; return 1; }

rm -vrf QuickTime/downloads/* MS\ Internet\ Cache/* Mail/* Safari/* Acrobat/7.0/Search70/* \
DashboardClient/* Desktop/* Java\ Applets/cache/* SuperDuper!/* VersionTracker\ Pro/* \
bridge1/* com.apple.SoftwareUpdate/* com.apple.helpui/*

}

err=`body 2&>1`

[ -n "$err" ] && echo "$err" | /Users/root/bin/dropmail "Cache Cleanup"

----

That's odd, I haven't gotten mail from it since 8/21/05.

ll /Users/root/Library/Caches/Safari/*
/Users/root/Library/Caches/Safari/01:
total 0
drwx------ 3 root wheel 102 Sep 6 04:17 .
drwx------ 10 root wheel 340 Sep 6 04:17 ..
drwx------ 3 root wheel 102 Sep 6 04:17 07

/Users/root/Library/Caches/Safari/02:
total 0
drwx------ 4 root wheel 136 Sep 6 04:17 .
drwx------ 10 root wheel 340 Sep 6 04:17 ..
drwx------ 3 root wheel 102 Sep 6 04:17 10
drwx------ 3 root wheel 102 Sep 6 04:17 14
[snip]


sh -x /Users/root/bin/Cache_cleanups.sh
++ body 2
+ err=
+ '[' -n '' ']'


Hey! That ain't right! Where's my delete trace!?!
It *did* delete the above cache files.

That '2' after "++body 2" should NEVER have been visible in the trace.
What's with this fake Bourne shell? It was working for a couple months,
then it just stops?

I moved around the mapping of stderr onto stdout, and it started working
again, sheesh.

cat /Users/root/bin/Cache_cleanups.sh
#!/bin/sh

body() {

exec 2>&1

cd /Users/root/Library/Caches || { echo "Can't make current the Cache
directory!"; return 1; }

rm -vrf QuickTime/downloads/* MS\ Internet\ Cache/* Mail/* Safari/* Acrobat/7.0/Search70/* \
DashboardClient/* Desktop/* Java\ Applets/cache/* SuperDuper!/* VersionTracker\ Pro/* \
bridge1/* com.apple.SoftwareUpdate/* com.apple.helpui/*

}

err=`body`

[ -n "$err" ] && echo "$err" | /Users/root/bin/dropmail "Cache Cleanup"


sh -x /Users/root/bin/Cache_cleanups.sh
++ body
++ exec
+ err=++ cd /Users/root/Library/Caches
++ rm -vrf 'QuickTime/downloads/*' 'MS Internet Cache/*' 'Mail/*' Safari/00 Safari/01 Safari/02 Safari/03 Safari/04 Safari/05 Safari/06 Safari/07 Safari/08 Safari/09 Safari/10 Safari/11 Safari/12 Safari/13 Safari/14 Safari/15 'Acrobat/7.0/Search70/*' 'DashboardClient/*' 'Desktop/*' 'Java Applets/cache/*' 'SuperDuper!/*' 'VersionTracker Pro/*' 'bridge1/*' 'com.apple.SoftwareUpdate/*' 'com.apple.helpui/*'
+ /Users/root/bin/dropmail 'Cache Cleanup'
+ echo '++ cd /Users/root/Library/Caches
++ rm -vrf '\''QuickTime/downloads/*'\'' '\''MS Internet Cache/*'\''
'\''Mail/*'\'' Safari/00 Safari/01 Safari/02 Safari/03 Safari/04
Safari/05 Safari/06 Safari/07 Safari/08 Safari/09 Safari/10 Safari/11
Safari/12 Safari/13 Safari/14 Safari/15 '\''Acrobat/7.0/Search70/*'\''
'\''DashboardClient/*'\'' '\''Desktop/*'\'' '\''Java Applets/cache/*'\''
'\''SuperDuper!/*'\'' '\''VersionTracker Pro/*'\'' '\''bridge1/*'\''
'\''com.apple.SoftwareUpdate/*'\'' '\''com.apple.helpui/*'\''


It's working again, but WTF??? Why did I have to make that edit?
(It works without the shell trace turned on too.)
.



Relevant Pages

  • Re: Are "Caches" directories safe to delete?
    ... > Is it safe to delete the contents of my system's Caches directories? ... > I was thinking of logging into the console and doing this, ... Cache files are, as you surmised, safe to delete. ...
    (comp.sys.mac.system)
  • Re: ASP.NET cache object thread safe?
    ... the documentation for the Cache class in the System.Web.Caching ... I would also assume that this is thread safe, but if you don't trust it, ... What I would like to do is introduce a cache to the middleware tier to cut ...
    (microsoft.public.dotnet.languages.csharp)
  • Does GetComInterfaceForObject pin the object?
    ... Marshal.GetComInterfaceForObject pins the object you call it on. ... that I mean that until you call Marshal.Release the returned IntPtr ... should have the same value and it's safe to cache it in native code. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Are "Caches" directories safe to delete?
    ... >> Is it safe to delete the contents of my system's Caches directories? ... > be created in the cache folders and you can empty the trash then. ... Unix systems won't really delete open files anyway. ...
    (comp.sys.mac.system)
  • Re: Are "Caches" directories safe to delete?
    ... > Is it safe to delete the contents of my system's Caches directories? ... be created in the cache folders and you can empty the trash then. ...
    (comp.sys.mac.system)