/var is a standard directory of any Linux/UNIX system - it stands for "variable" and is a place where a lot of logs, cahces, BUT also program variable settings files and even some system configuration databases reside.
You should be very careful about just deleting things in any of the hidden system folders, especially if you are thinking of just deleting whole directories (and you probably do not have permission for many of those, even as admin, as they will be specifically owned by root).
Most things in /var should be properly purged and regulated by the system. Your swap files for virtual memory also live in /var so don't mess with that. /var/run also holds a lot status and parameter information of actively running process daemans.
/var may very well get large at times - if you are using a lot of swap, for example, or /var/tmp may fill up with temp files during a long session with a single app and many files. But, for the most part, the system will handle cleaning up when necessary, and if you delete things yourself, you are highly likely to get unexpected and highly undesirable results.
I'm aware of the importance of /var/ and the foolishness of messing with it.
However I'm also aware of what most of the folders inside it are for. /folders/ is new to me, and as it seems to only be cache and tmp files, I was wondering what exactly it is, and what it's used for. Any ideas? I've tried googling it but there's not much info, except a bunch of others like me complaining that its size is ballooning...
To my memory, /var/folders came to being with OS X 10.5 as a more obscure place for what used to be
/Library/Caches. And instead of being world read/writeable, it should now be user specific.
It should be safe to clear out if you've closed whatever you had running. Safari seems to be a big culprit for writing there, caching junk from every web page you visit. I have read that some systems monitoring tools are also notorious for filling it up (they cache data for logs supposedly).
Do not tamper with /var in any way. If you want to get some space back then reboot. The system will clear out what it deems needs clearing out. That includes your swap space which may build up over time if you don't reboot and have insufficient ram.
Erase stuff in there at your own risk.
As for /var/folders, I don't think you can remove any of that stuff anyhow since I think you have to log in as "root" to remove it.
Also note, if you are so low on disk space that you are concerned about just 200MB then IMO you are headed for bigger problems anyhow. You should always leave about 20GB to 25GB just for the OS to operate efficiently.
Some of these caches and logs have grown to gigantic sized, the entire folder is about 200MB at this stage, and they remain even though I used Onyx and Cocktail to clear out caches.
IMHO, you're looking for headaches. My </var/folders> is >400MB (real size, not Finder's) and I haven't noticed any slowdown. As X423424X says, 200MB is nothing -- certainly not worth the time it took you to write your OP. FWIW, my advice is, leave </var> severely alone. If your system is slowing down, look elsewhere. Start by doing a simple Safe Boot followed by a normal boot.
Even if you were to save some disk space by deleting those files, they will get recreated fairly soon anyway. You can delete the daily.out file, for example, safely, but it will just get recreated during background system maintenance.
On my Macs, by far the biggest space hog in the /private/var areas is the sleepimage file inside /private/var/vm and that is a file you do not want to delete. It's the file that all the contents of your memory is written to when you put your Mac to sleep. On my laptop it is 4 GB in size (equal in size to the amount of RAM), so deleting 200 MB here or there pales in comparison.
It's and old post but still useful.
Yes, you can delete the contents safely but it isn't important to do so. Don't delete anything else in /var/ and you will be fine. It won't do you any good, however, so just leave it alone.
Onyx, Cocktail, "cache cleaning" and "defragging" apps are a waste of time and money and won't do you any good either. Nothing will go faster. Apps running in the background slow you down, like antivirus and maintenence software. Caches speed things up, that's their function. This software you have seems to be helping and making your mac better, but are ultimately worthless and I've administered many severe duty Macs. Kind of the way your car feels faster after an oil change. It ain't faster. It's possible for logs to grow out of control, but we have terabyte hard drives for $99 now so what's the real space issue?
Glad to see you digging in system folders. This is good education. Play in there but don't feel you need to delete anything or for pete's sake "clean" anything. That complexity is normal, not something to be feared or changed. Learn about Unix, especially BSD, and get a bigger hard disk.
Not sure how this got bumped after a year
Basically my Macbook is from early 2007 and recently it's been amazingly, mind numbingly slow.
I've deduced that the culprit is my hard drive for one simple reason - paging literally kills it. I know that paging out slows things down, but in my case, I can watch activity monitor and literally the minute I get even a few kb of "swap used", the fans rev up and the entire system just grinds to a halt, and remains so until my next reboot.
Can only assume that the motors on the HD aren't what they once were and can't keep up anymore. So basically I do as much defragging, space clearing etc as I can just to help the disk out in any way I can. Just did another big maintainance, Onyx, Cocktail and Techtool Pro, and I'm running a lot faster.
The problem is two fold essentially - the machine starts dying slowly once it has to page, andSafari 5 has the most appalling memory leak which inevitably leads to paging out after a matter of time, unless you're willing to quit Safari Web Content (thereby force reloading every tab) every couple of minutes. You can tell it's a memory leak bug because once it's finished reloading all pages, the RAM usage by SWC is never even half as high as it was before you quit it :/
Reckon the only way out of this is to get a new Macbook as soon as I can. Don't want to throw that kind of cash around atm but it's looking like pretty soon I won't have any choice
It's bumped because it still matters so I replied to it. It's now Jan 2012 deleting the contents of /folders/ is still fashionable and so is mucking with so called "maintenance" apps.
That and you still replied :) so you, the OP, feel you still want conversation on this topic. That's fine.
Sorry to say but the maintenance apps you use don't affect paging, or the VM system. The motors on your HD, if dying, will cause error. Your post betrays a fundamental misunderstanding of macOS.
By what mechanism, precisely, is the reason your "big maintenance" is causing you to run faster? Making space on afull HD can cause this but again if you are running out of space (going on a year now) the small amount of cache deleting isn't your long term solution. Defragging, sheesh. Absolutely silly and really senseless if your HD is really failing because defragging is a whole lot of unnecessary HD access.
Instead of getting to the bottom of the issue you made running a bunch of dumb apps part of your routine. Your Mac needs no maintenance only a small amount of free HD space to operate just fine. If you indeed have a runaway log file or rogue app solve that issue instead of deleting /var/folders/ all the time.
Actually you've said it, something with Safari or a page you are viewing is hanging your Mac . Troubleshoot your installed plugins on Safari if you have any or use a different browser such as Firefox to access that particular web page if necessary. Force quit the Safari process see if the CPU use drops in Activity Monitor.
In fairness my case might be different in terms of defragmenting.
Apple themselves acknowledge that while OS X does in fact automatically defragment continuously as part of its own background maintenance, it won't handle files bigger than (I think) 30MB, could possibly be 40MB, I can't quite remember.
Problem is that I'm a music producer so I work with absolutely gigantic files a lot of the time, and they are the only files which continuously show up in Techtool as fragmented files. This causes programs such as Garageband and Logic to load them more slowly, and as I say I noticed an instant improvement in response time for those apps as soon as I'd defragmented the files.
The real issue though is that this fragmentation also leads to a lack of contiguous free space on the disk. When this happens, the page file itself gets fragmented, and it seems obvious to me that a fragmented page file will make paging a lot less efficient.
Either way, after running both file and volume defragmentation things are a lot faster. I also rebuiltthe directory which reduced the depth of the B-Tree from 4 to 3, and there's a definite improvement in how quickly finder generates previews and lists the contents of folders.
Finally, I'm afraid the Safari problem has nothing to do with plugins (I don't actually use any most of the time), and Firefox can indeed visit the same websites without eating up my entire available RAM. Have a look around this forum, the fact that Safari has a notorious memory leak is fairly widely acknowledged. You can tell it's a leak since closing every window doesn't result in any RAM becoming inactive, and also that force quitting Safari Web Content and letting it relopad every page usually halves the amount of RAM being used. Clearly the process does not release RAM it was previously using, until it is restarted.
Unfortunate, but manageable.
We're getting far afield, but if you use a 2007 MBP (with 1GB or RAM and about 150GB drive?) as a music producer with "gigantic files" and you are using defrag apps and deleting the contents of /var/folders/ for speed your workflow is not efficient.
Buy a $99 external Two terabyte USB2 HD for your media and keep some space open on your boot drive. A few GB will do. And get back to work!
But really consider a faster setup for Logic and GarageBand or any media production. Better yet, get a modern Mac Mini for less than a grand with a terabyte HD which is a fantastic solution for music production and will end your current speed issues. You don't need much tech and I have friends that do amazing things musically with 90's era computing technology.
Defraggging is a waste of time, even for your use case. It's frankly indefensible.
Read this (2004) about HFS+ volumes http://osxbook.com/software/hfsdebug/fragmentation.html
(read the whole thing). Remember that things are better now than they were then and it wasn't fruitful then. Furthermore, if you thrash the HD a bunch with a nearly empty drive you are asking for trouble and defragging can't buy you any improvement that lasts past the next big file write. Get a larger drive and keep a bunch of GB open on it is your best solution and frankly it's cheap. Isn't your time (and downtime during defrag) worth money?
It's a bit strange because you know the depth of your B-Tree(!) which is esoteric data and probably printed on the GUI of your defrag app to make you feel like you did something with the app you paid for. Kind of like the oil change sticker Jiffy Lube leaves in your windshield after you paid them $50. Forget that stuff because reducing B-Tree depth doesn't correlate to any speed increase directly and doesn't have any effect you can feel.
I'm starting to think all of your mucking with your boot drive's directory structure and file structure over the last year has created an oddball issue.
Compressing the directory structure to reduce your B-Tree depth is about the silliest thing I've heard. You know enough to be dangerous.
You Windows converts are crazy. You don't need to defrag for your use case, cache cleaning does not replace registry cleaning, your Mac does not need periodic maintenance, and there are no viruses only trojans (stop downloading and installing stuff!)
If you have a specific problem, don't make it worse by guesssing. Troubleshoot and fix the issue.