We have fleets of laptops that have limited space once our software is installed on it. What ever the issue that is causing the creation of theses files and --err not flushing them, we are ignoring for the moment. But I would like to automatically delete the contents /private/var/folders/. We have maybe 5-10 students log in to a laptop a day. Not sure if that will be an overkill. Any help would be appreciated.
It's a simple way. You can use the
getconf DARWIN_USER_CACHE_DIR command to get the per-user temporary files and caches directory. and remove it. edit the '/etc/profile' file, add the following codes in it(not test yet):
userTempDir=`/usr/bin/getconf DARWIN_USER_CACHE_DIR` rm -fr $userTempDir*
You could try (for free) this app https://www.peterborgapps.com/lingon/
Run what you want, whenever you want
Lingon can start an app, a script or run a command automatically whenever you want it to. You can schedule it to run at a specific time, regularly or when something special happens.
Or you could write your own script that contains the
sudo rm -rf /private/var/log/* command
This is probably sorted out by now, but for future readers:
do shell script "rm /private/var/folders/"
error that says: error "rm: /private/var/folders/ : is a directory"
rm -r to remove a directory and it's contents. However, I would suggest that if you don't already know that detail, then perhaps destructive shell commands are not for you.
rm -r /private/var/folders/*
rm -r /private/var/folders /*
One erases temporary cache folders, the other erases the entire drive. Can you see why?
Deleting /private/var/folders/ won't solve your space problem. Cached files are there for system performance. If you erase them the system will just refill the directory. If you are so short of space that 1.5Gb makes a difference you need to take a critical look at either your installed software or your drive size.