[Bob Rudis of The Apple Blog has a recent article on how you use CLIX for things like this - and a lot else too. Ed.]

10.5 Leopard represents a step forward - but it also represents new challenges to those interested in keeping their machines clean lean and mean. New caches are strewn all over the place; these caches can make ordinary operations run faster and smoother; but there can be times when you simply want them gone - when the system doesn't take adequate care of itself.

/private/var/folders

A new location for system and user caches is found at /private/var/folders. Leopard 10.5 systems should have two subdirectories at this point; and their names are installation dependent - they'll vary from machine to machine. Two levels further down the hierarchy are represented by one two-character directory and below that a second directory with a name 27 characters or more in length. An attempt seems to have been made to thwart entrance from the command line but of course nothing's impossible - the names namely contain a lot of 'weird' characters that often conflict with Unix shell operations.

The first subdirectory under /private/var/folders is for user caches; the second for system caches. The commands that follow won't touch the system caches (for obvious reasons).

The three user cache subdirectories with actual contents are called '-Caches-', '-Tmp-', and 'TemporaryFiles'. The system caches have the same layout but with six separate 'trees' for the same number system accounts. The system accounts are for _atsserver, _installer, _mdnsresponder, nobody, root, and _securityagent.

What Builds Up

The contents of the user '-Cache-' hive can grow to monstrous proportions. Safari caches can grow to several hundred MB. Other caches will appear and you'll have no idea how they got there. Leopard seems to love to cache stuff all over the place. And if you're particular on watching your disk free space this can throw you for a loop. When that happens: look first inside /private/var/folders.

Apple's Preview leaves heaps of junk in '-Tmp-': a directory created and left behind for every file you open.

~/Library/Caches

Already from the Tiger era ~/Library/Caches could display fantastic behaviour: position yourself there so you're watching what happens and then just open and close 'System Preferences'. You should see two files immediately appear - eating up a good 5-6 MB disk space. And all you did was open and close the program.

You might feel they're good to keep; you can hope they won't mutate with time; you might on the other hand try removing them and running 'System Preferences' again to see things still work OK. [Which they definitely do.] So you might decide you can live with these two files gone as well. [Good decision.]

~/Library/Caches/Software Update

Be sure to check out '~/Library/Caches/Software Update' as well - this type of cache resembles what Safari traditionally stores and can grow to several MB with no apparent benefit to you.

Remember: your system can live without caches. But caches can often speed up computer operations - including your login. Leopard is blazing fast at logins - removing too many caches in the '/private/var/folders' hive can slow logins down. The logins will still work OK - they'll just be slower: the system will want to recreate these caches before turning the controls over to you.

Remember: not all caching systems are well thought out. Software can have a tremendous propensity for literally littering your system with totally useless junk. And if you want a clean lean and mean machine you'll have to take care of this yourself.

グラフィックトライブへ

Dali Rău of Graphic Tribe runs 4-5 Leopard boxes in tandem. [He needs this power for graphics rendering - click here and click here. Ed.] Some of the software used by Graphic Tribe really gets ambitious with caching and Leopard helps them along fabulously. It is therefore important to clean up the hardware on a regular basis if they're to be used for this type of crunching again.

What follow are some of the cleanup scripts used by Graphic Tribe. They're used mostly in conjunction with rebooting - some run before the reboot, some run afterwards. As always: 'YMMV'. They're yours to try - but only 'as is'.

beforeReboot.sh

This is the most important part of the cleanup. It's about getting a box ready to use (abuse) again. This script will automatically reboot your computer when the cleaning's done - so be sure to close down all other operations before you begin.

The script assumes the presence of xabatch to remove unwanted extended attributes. Comment out the appropriate lines if you don't have it.

[Note: this script will not run 'as is': line breaks have been introduced for readability. Click on the code itself to download a functional copy. Ed.]

Scripts & sudo

Both of the above scripts need to be invoked with sudo to run correctly.

Caution is always advised when invoking sudo on scripts. Their contents have to be adequately protected. Your system has an option to allow SUID bits on scripts but it's normally turned off for the same reason. There can be occasions such as the above scripts when using sudo can't easily be avoided; just be careful.

And Now with CLIX!

Of course you can reduce all of this to a few mouse clicks. That's the point! And it's free too. That's another good point!